Matchmaking
The precompiles Matchmaking in zytron kit
Matchmaking SDK
We provide Rust, Javascript (WebAssembly based) and C (FFI support) SDK.
Rust Crate
Crate Name | crates | docs.rs |
---|---|---|
zmatchmaking |
Add dependency to Cargo.toml
zmatchmaking = "0.1"
Use the following code:
let mut rng = ChaChaRng::from_entropy();
let inputs = (1..=N)
.into_iter()
.map(|i| Fr::from(i as u64))
.collect::<Vec<_>>();
let committed_seed = Fr::rand(&mut rng);
let committment = AnemoiJive254::eval_variable_length_hash(&[committed_seed]);
let random_number = Fr::rand(&mut rng);
let (proof, outputs) = prove_matchmaking(
&mut rng,
&inputs,
&committed_seed,
&random_number,
&gen_prover_params().unwrap(),
)
.unwrap();
let verifier_params = bincode::serialize(&get_verifier_params().unwrap()).unwrap();
let inputs = inputs
.iter()
.map(|v| Token::Bytes(v.into_bigint().to_bytes_be()))
.collect();
let outputs = outputs
.iter()
.map(|v| Token::Bytes(v.into_bigint().to_bytes_be()))
.collect();
let committment = committment.into_bigint().to_bytes_be();
let random_number = random_number.into_bigint().to_bytes_be();
let proof = bincode::serialize(&proof).unwrap();
let data = ethabi::encode(&[
Token::Bytes(verifier_params),
Token::Array(inputs),
Token::Array(outputs),
Token::Bytes(committment),
Token::Bytes(random_number),
Token::Bytes(proof),
]);
Javascript SDK
TODO
C SDK
TODO