Skip to main content

Example

Call curves in ink!#

curveaddmulpairing
bls12_3770x010000000x010000010x01000002
bls12_3810x010000100x010000110x01000012
bn2540x010000200x010000210x01000022
bw6_7610x010000300x010000310x01000032
let result = ink_env::call_chain_extension(func_id, &Vec::from(input))?

MIMC#

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#

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