Example
Call curves in ink!
curve | add | mul | pairing |
---|---|---|---|
bls12_377 | 0x01000000 | 0x01000001 | 0x01000002 |
bls12_381 | 0x01000010 | 0x01000011 | 0x01000012 |
bn254 | 0x01000020 | 0x01000021 | 0x01000022 |
bw6_761 | 0x01000030 | 0x01000031 | 0x01000032 |
#![allow(unused)] fn main() { let result = ink_env::call_chain_extension(func_id, &Vec::from(input))? }
MIMC
#![allow(unused)] fn main() { use zkp_u256::{U256, Zero}; use merkle_tree::mimc::{mimc,mimc_with_key} let message = U256::from_decimal_str("49").unwrap(); let in_key = U256::zero(); assert_eq!( mimc(b"1"), mimc_with_key(vec![&message], &in_key) ); }
Merkle Tree
#![allow(unused)] fn main() { use merkle_tree::MerkleTree; let mut mt = MerkleTree::default(); let message = b"49"; let (leaf, index) = mt.insert(message).unwrap(); assert_eq!(mt.update(), mt.get_root()); let merkle_proof = mt.get_proof(index); assert!(mt.verify_merkle_proof(leaf, merkle_proof, index)); let message = b"50"; let (leaf, index) = mt.insert(message).unwrap(); assert_eq!(mt.update(), mt.get_root()); let merkle_proof = mt.get_proof(index); assert!(mt.verify_merkle_proof(leaf, merkle_proof, index)); let message = b"51"; let (leaf, index) = mt.insert(message).unwrap(); assert_eq!(mt.update(), mt.get_root()); let merkle_proof = mt.get_proof(index); assert!(mt.verify_merkle_proof(leaf, merkle_proof, index)); }
EDDSA
TODO