This repository demonstrates the implementation of a "Lock-and-Mint" bridge between Peercoin and an EVM-compatible blockchain, utilizing an oracle secured by threshold cryptography.
This method can connect Peercoin with Ethereum or allow for sidechains running as companion chains to Peercoin. The process is straightforward conceptually: coins are locked on Peercoin, after which equivalent wrapped tokens are minted on the destination chain (E). When users wish to reverse the process, they burn these wrapped tokens on Chain E, generating proof that allows unlocking of the original coins on Peercoin. However, there is a catch: neither of chains cannot directly observe or verify events on the other.
To bridge this communication gap, a consortium of external Witness nodes (oracles). In this case a ROAST swarm of witnesses is simulated by a single schnor signature produced with coinlib. Witnesses observe both blockchains without directly interacting with neither. Upon reaching internal consensus, they issue cryptographically signed attestations verifying events like locking or burning of tokens.
By employing a threshold cryptography approach, a large consortium of Witnesses can collaboratively and securely validate events without any single trusted entity controlling the attestation process.
Solidity code is adopted from now defunct (?) ZeroDAO.
https://github.com/zerodao-finance/bip340-solidity/
They seem to have adopted it from the original idea I stumbled upon about two years ago: https://hackmd.io/@nZ-twauPRISEa6G9zg3XRw/SyjJzSLt9 and few other sources like Witnet.
I am confindent this is properly implemented and works as promised.
thresholdWrappedPeercoin.sol
is the main file, where the token magic happens.
It is a simple demonstrator, basically it allows minting of a token if caller provides a valid BIP340 signature from the witness oracle.
This acts as an Oracle, producing a BIP340-stlye signature.
Dart code is pretty simple, it:
- derives a pubkey,
- prints out X value of it,
- prints out keccak hash of the attestation,
- then signs the attestation hash with privkey.