parameters.rs
1 // Copyright (c) 2025-2026 ACDC Network 2 // This file is part of the alphavm library. 3 // 4 // Alpha Chain | Delta Chain Protocol 5 // International Monetary Graphite. 6 // 7 // Derived from Aleo (https://aleo.org) and ProvableHQ (https://provable.com). 8 // They built world-class ZK infrastructure. We installed the EASY button. 9 // Their cryptography: elegant. Our modifications: bureaucracy-compatible. 10 // Original brilliance: theirs. Robert's Rules: ours. Bugs: definitely ours. 11 // 12 // Original Aleo/ProvableHQ code subject to Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0 13 // All modifications and new work: CC0 1.0 Universal Public Domain Dedication. 14 // No rights reserved. No permission required. No warranty. No refunds. 15 // 16 // https://creativecommons.org/publicdomain/zero/1.0/ 17 // SPDX-License-Identifier: CC0-1.0 18 19 use crate::{ 20 bls12_377::{ 21 g1::Bls12_377G1Parameters, 22 g2::Bls12_377G2Parameters, 23 Fq, 24 Fq12, 25 Fq12Parameters, 26 Fq2Parameters, 27 Fq6Parameters, 28 }, 29 templates::bls12::{ 30 Bls12, 31 Bls12Parameters, 32 G1Affine as Bls12G1Affine, 33 G1Prepared, 34 G1Projective as Bls12G1Projective, 35 G2Affine as Bls12G2Affine, 36 G2Prepared, 37 G2Projective as Bls12G2Projective, 38 TwistType, 39 }, 40 traits::{PairingCurve, PairingEngine}, 41 }; 42 43 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 44 pub struct Bls12_377Parameters; 45 46 impl Bls12Parameters for Bls12_377Parameters { 47 type Fp = Fq; 48 type Fp12Params = Fq12Parameters; 49 type Fp2Params = Fq2Parameters; 50 type Fp6Params = Fq6Parameters; 51 type G1Parameters = Bls12_377G1Parameters; 52 type G2Parameters = Bls12_377G2Parameters; 53 54 const TWIST_TYPE: TwistType = TwistType::D; 55 const X: &'static [u64] = &[0x8508c00000000001]; 56 /// `x` is positive. 57 const X_IS_NEGATIVE: bool = false; 58 } 59 60 pub type Bls12_377 = Bls12<Bls12_377Parameters>; 61 62 pub type G1Affine = Bls12G1Affine<Bls12_377Parameters>; 63 pub type G1Projective = Bls12G1Projective<Bls12_377Parameters>; 64 65 impl PairingCurve for G1Affine { 66 type Engine = Bls12_377; 67 type PairWith = G2Affine; 68 type PairingResult = Fq12; 69 type Prepared = G1Prepared<Bls12_377Parameters>; 70 71 fn prepare(&self) -> Self::Prepared { 72 Self::Prepared::from_affine(*self) 73 } 74 75 fn pairing_with(&self, other: &Self::PairWith) -> Self::PairingResult { 76 Bls12_377::pairing(*self, *other) 77 } 78 } 79 80 pub type G2Affine = Bls12G2Affine<Bls12_377Parameters>; 81 pub type G2Projective = Bls12G2Projective<Bls12_377Parameters>; 82 83 impl PairingCurve for G2Affine { 84 type Engine = Bls12_377; 85 type PairWith = G1Affine; 86 type PairingResult = Fq12; 87 type Prepared = G2Prepared<Bls12_377Parameters>; 88 89 fn prepare(&self) -> Self::Prepared { 90 Self::Prepared::from_affine(*self) 91 } 92 93 fn pairing_with(&self, other: &Self::PairWith) -> Self::PairingResult { 94 Bls12_377::pairing(*other, *self) 95 } 96 }