initial commit of src template
This commit is contained in:
parent
0a2b1f811c
commit
3eeb5fbfe6
|
@ -0,0 +1,15 @@
|
||||||
|
[package]
|
||||||
|
|
||||||
|
name = "libbolt"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["J. Ayo Akinyele <ayo@yeletech.org>"]
|
||||||
|
description = "library for Blind Off-chain Lightweight Transactions (BOLT)"
|
||||||
|
keywords = ["zcash", "payment channels", "bolt"]
|
||||||
|
readme = "README.md"
|
||||||
|
homepage = "https://github.com/yeletech/libbolt"
|
||||||
|
repository = "https://github.com/yeletech/libbolt"
|
||||||
|
license = "MIT License"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bn = "0.4.3"
|
||||||
|
rand = "~0.3.14"
|
|
@ -0,0 +1,26 @@
|
||||||
|
extern crate bn;
|
||||||
|
extern crate rand;
|
||||||
|
use bn::{Group, Fr, G1, G2, pairing};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let rng = &mut rand::thread_rng();
|
||||||
|
|
||||||
|
// Generate private keys
|
||||||
|
let alice_sk = Fr::random(rng);
|
||||||
|
//println!("alice_sk: {}", alice_sk);
|
||||||
|
let bob_sk = Fr::random(rng);
|
||||||
|
let carol_sk = Fr::random(rng);
|
||||||
|
|
||||||
|
// Generate public keys in G1 and G2
|
||||||
|
let (alice_pk1, alice_pk2) = (G1::one() * alice_sk, G2::one() * alice_sk);
|
||||||
|
let (bob_pk1, bob_pk2) = (G1::one() * bob_sk, G2::one() * bob_sk);
|
||||||
|
let (carol_pk1, carol_pk2) = (G1::one() * carol_sk, G2::one() * carol_sk);
|
||||||
|
|
||||||
|
// Each party computes the shared secret
|
||||||
|
let alice_ss = pairing(bob_pk1, carol_pk2).pow(alice_sk);
|
||||||
|
let bob_ss = pairing(carol_pk1, alice_pk2).pow(bob_sk);
|
||||||
|
let carol_ss = pairing(alice_pk1, bob_pk2).pow(carol_sk);
|
||||||
|
|
||||||
|
assert!(alice_ss == bob_ss && bob_ss == carol_ss);
|
||||||
|
println!("All bn tests succeeded!");
|
||||||
|
}
|
Loading…
Reference in New Issue