#[repr(C)]pub struct Gt(/* private fields */);
Implementations§
source§impl Gt
impl Gt
pub fn one() -> Self
sourcepub fn pow(&self, exp: Fr) -> Self
pub fn pow(&self, exp: Fr) -> Self
Examples found in repository?
examples/joux.rs (line 20)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() {
let mut rng = rand::thread_rng();
// Generate private keys
let alice_sk:Fr = rng.gen();
let bob_sk:Fr = rng.gen();
let carol_sk:Fr = rng.gen();
// 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);
}
pub fn inverse(&self) -> Self
pub fn into_bytes(&self) -> Vec<u8>
Trait Implementations§
source§impl<'de> Deserialize<'de> for Gt
impl<'de> Deserialize<'de> for Gt
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Distribution<Gt> for Standard
impl Distribution<Gt> for Standard
impl Copy for Gt
impl Eq for Gt
impl SerializableGt for Gt
impl StructuralPartialEq for Gt
Auto Trait Implementations§
impl Freeze for Gt
impl RefUnwindSafe for Gt
impl Send for Gt
impl Sync for Gt
impl Unpin for Gt
impl UnwindSafe for Gt
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more