EdOnBN254(BabyJubJub)

The precompiles EdOnBN254(BabyJubJub) in zytron kit

EdOnBN254 SDK

We provide Solidity, Rust, Javascript (WebAssembly based) and C (FFI support) SDK.

Rust Crate

Crate Namecratesdocs.rs
uzkge

Add dependency to Cargo.toml

uzkge = "0.1"

Use the following code for ADD:

let mut prng = ChaChaRng::from_seed([0u8; 32]);
let p1 = EdwardsAffine::rand(&mut prng);
let p2 = EdwardsAffine::rand(&mut prng);
let (p1_0, p1_1) = p1.xy().unwrap();
let (p2_0, p2_1) = p2.xy().unwrap();

let p1_x = U256::from_big_endian(&p1_0.into_bigint().to_bytes_be());
let p1_y = U256::from_big_endian(&p1_1.into_bigint().to_bytes_be());
let p2_x = U256::from_big_endian(&p2_0.into_bigint().to_bytes_be());
let p2_y = U256::from_big_endian(&p2_1.into_bigint().to_bytes_be());

let data = ethabi::encode(&[
    Token::Uint(p1_x),
    Token::Uint(p1_y),
    Token::Uint(p2_x),
    Token::Uint(p2_y),
]);

Use the following code for MUL:

let mut prng = ChaChaRng::from_seed([0u8; 32]);
let s = Fr::rand(&mut prng);
let p1 = EdwardsAffine::rand(&mut prng);
let (p1_0, p1_1) = p1.xy().unwrap();

let scalar = U256::from_big_endian(&s.into_bigint().to_bytes_be());
let p1_x = U256::from_big_endian(&p1_0.into_bigint().to_bytes_be());
let p1_y = U256::from_big_endian(&p1_1.into_bigint().to_bytes_be());

let data = ethabi::encode(&[Token::Uint(scalar), Token::Uint(p1_x), Token::Uint(p1_y)]);

Javascript SDK

TODO

C SDK

TODO