commit
9bfb935a6e
|
@ -20,6 +20,7 @@ use crate::Scalar;
|
||||||
///
|
///
|
||||||
/// Values of `G1Affine` are guaranteed to be in the $q$-order subgroup unless an
|
/// Values of `G1Affine` are guaranteed to be in the $q$-order subgroup unless an
|
||||||
/// "unchecked" API was misused.
|
/// "unchecked" API was misused.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "groups")))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct G1Affine {
|
pub struct G1Affine {
|
||||||
pub(crate) x: Fp,
|
pub(crate) x: Fp,
|
||||||
|
@ -414,6 +415,7 @@ impl G1Affine {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is an element of $\mathbb{G}_1$ represented in the projective coordinate space.
|
/// This is an element of $\mathbb{G}_1$ represented in the projective coordinate space.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "groups")))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct G1Projective {
|
pub struct G1Projective {
|
||||||
x: Fp,
|
x: Fp,
|
||||||
|
|
|
@ -21,6 +21,7 @@ use crate::Scalar;
|
||||||
///
|
///
|
||||||
/// Values of `G2Affine` are guaranteed to be in the $q$-order subgroup unless an
|
/// Values of `G2Affine` are guaranteed to be in the $q$-order subgroup unless an
|
||||||
/// "unchecked" API was misused.
|
/// "unchecked" API was misused.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "groups")))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct G2Affine {
|
pub struct G2Affine {
|
||||||
pub(crate) x: Fp2,
|
pub(crate) x: Fp2,
|
||||||
|
@ -486,6 +487,7 @@ impl G2Affine {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is an element of $\mathbb{G}_2$ represented in the projective coordinate space.
|
/// This is an element of $\mathbb{G}_2$ represented in the projective coordinate space.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "groups")))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct G2Projective {
|
pub struct G2Projective {
|
||||||
pub(crate) x: Fp2,
|
pub(crate) x: Fp2,
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
//! * All operations are constant time unless explicitly noted.
|
//! * All operations are constant time unless explicitly noted.
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
// Catch documentation errors caused by code changes.
|
// Catch documentation errors caused by code changes.
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![deny(missing_debug_implementations)]
|
#![deny(missing_debug_implementations)]
|
||||||
|
|
|
@ -19,6 +19,7 @@ use alloc::vec::Vec;
|
||||||
/// Represents results of a Miller loop, one of the most expensive portions
|
/// Represents results of a Miller loop, one of the most expensive portions
|
||||||
/// of the pairing function. `MillerLoopResult`s cannot be compared with each
|
/// of the pairing function. `MillerLoopResult`s cannot be compared with each
|
||||||
/// other until `.final_exponentiation()` is called, which is also expensive.
|
/// other until `.final_exponentiation()` is called, which is also expensive.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "pairings")))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct MillerLoopResult(pub(crate) Fp12);
|
pub struct MillerLoopResult(pub(crate) Fp12);
|
||||||
|
|
||||||
|
@ -180,6 +181,7 @@ impl_add_binop_specify_output!(MillerLoopResult, MillerLoopResult, MillerLoopRes
|
||||||
///
|
///
|
||||||
/// Typically, $\mathbb{G}_T$ is written multiplicatively but we will write it additively to
|
/// Typically, $\mathbb{G}_T$ is written multiplicatively but we will write it additively to
|
||||||
/// keep code and abstractions consistent.
|
/// keep code and abstractions consistent.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "pairings")))]
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
pub struct Gt(pub(crate) Fp12);
|
pub struct Gt(pub(crate) Fp12);
|
||||||
|
|
||||||
|
@ -449,6 +451,7 @@ impl Group for Gt {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "pairings", feature = "alloc"))))]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
/// This structure contains cached computations pertaining to a $\mathbb{G}_2$
|
/// This structure contains cached computations pertaining to a $\mathbb{G}_2$
|
||||||
/// element as part of the pairing function (specifically, the Miller loop) and
|
/// element as part of the pairing function (specifically, the Miller loop) and
|
||||||
|
@ -509,6 +512,7 @@ impl From<G2Affine> for G2Prepared {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "pairings", feature = "alloc"))))]
|
||||||
/// Computes $$\sum_{i=1}^n \textbf{ML}(a_i, b_i)$$ given a series of terms
|
/// Computes $$\sum_{i=1}^n \textbf{ML}(a_i, b_i)$$ given a series of terms
|
||||||
/// $$(a_1, b_1), (a_2, b_2), ..., (a_n, b_n).$$
|
/// $$(a_1, b_1), (a_2, b_2), ..., (a_n, b_n).$$
|
||||||
///
|
///
|
||||||
|
@ -565,6 +569,7 @@ pub fn multi_miller_loop(terms: &[(&G1Affine, &G2Prepared)]) -> MillerLoopResult
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invoke the pairing function without the use of precomputation and other optimizations.
|
/// Invoke the pairing function without the use of precomputation and other optimizations.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "pairings")))]
|
||||||
pub fn pairing(p: &G1Affine, q: &G2Affine) -> Gt {
|
pub fn pairing(p: &G1Affine, q: &G2Affine) -> Gt {
|
||||||
struct Adder {
|
struct Adder {
|
||||||
cur: G2Projective,
|
cur: G2Projective,
|
||||||
|
@ -749,6 +754,7 @@ impl PairingCurveAffine for G2Affine {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [`pairing::Engine`] for BLS12-381 pairing operations.
|
/// A [`pairing::Engine`] for BLS12-381 pairing operations.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "pairings")))]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Bls12;
|
pub struct Bls12;
|
||||||
|
|
||||||
|
|
|
@ -1030,6 +1030,8 @@ impl SubgroupPoint {
|
||||||
///
|
///
|
||||||
/// This should only be used for hard-coding constants (e.g. fixed generators); in all
|
/// This should only be used for hard-coding constants (e.g. fixed generators); in all
|
||||||
/// other cases, use [`SubgroupPoint::from_bytes`] instead.
|
/// other cases, use [`SubgroupPoint::from_bytes`] instead.
|
||||||
|
///
|
||||||
|
/// [`SubgroupPoint::from_bytes`]: SubgroupPoint#impl-GroupEncoding
|
||||||
pub const fn from_raw_unchecked(u: Fq, v: Fq) -> Self {
|
pub const fn from_raw_unchecked(u: Fq, v: Fq) -> Self {
|
||||||
SubgroupPoint(AffinePoint::from_raw_unchecked(u, v).to_extended())
|
SubgroupPoint(AffinePoint::from_raw_unchecked(u, v).to_extended())
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ readme = "README.md"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
aes = "0.5"
|
aes = "0.5"
|
||||||
blake2b_simd = "0.5"
|
blake2b_simd = "0.5"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//! `zcash_primitives` is a library that provides the core structs and functions necessary
|
//! `zcash_primitives` is a library that provides the core structs and functions necessary
|
||||||
//! for working with Zcash.
|
//! for working with Zcash.
|
||||||
|
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
// Catch documentation errors caused by code changes.
|
// Catch documentation errors caused by code changes.
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
|
|
||||||
|
|
|
@ -412,6 +412,7 @@ impl<P: consensus::Parameters, R: RngCore + CryptoRng> Builder<P, R> {
|
||||||
|
|
||||||
/// Adds a transparent coin to be spent in this transaction.
|
/// Adds a transparent coin to be spent in this transaction.
|
||||||
#[cfg(feature = "transparent-inputs")]
|
#[cfg(feature = "transparent-inputs")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "transparent-inputs")))]
|
||||||
pub fn add_transparent_input(
|
pub fn add_transparent_input(
|
||||||
&mut self,
|
&mut self,
|
||||||
sk: secp256k1::SecretKey,
|
sk: secp256k1::SecretKey,
|
||||||
|
|
|
@ -60,6 +60,7 @@ pub struct TxIn {
|
||||||
|
|
||||||
impl TxIn {
|
impl TxIn {
|
||||||
#[cfg(feature = "transparent-inputs")]
|
#[cfg(feature = "transparent-inputs")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "transparent-inputs")))]
|
||||||
pub fn new(prevout: OutPoint) -> Self {
|
pub fn new(prevout: OutPoint) -> Self {
|
||||||
TxIn {
|
TxIn {
|
||||||
prevout,
|
prevout,
|
||||||
|
|
|
@ -11,6 +11,9 @@ readme = "README.md"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bellman = { version = "0.6", path = "../bellman", default-features = false, features = ["groth16"] }
|
bellman = { version = "0.6", path = "../bellman", default-features = false, features = ["groth16"] }
|
||||||
blake2b_simd = "0.5"
|
blake2b_simd = "0.5"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//! `zcash_proofs` contains the zk-SNARK circuits used by Zcash, and the APIs for creating
|
//! `zcash_proofs` contains the zk-SNARK circuits used by Zcash, and the APIs for creating
|
||||||
//! and verifying proofs.
|
//! and verifying proofs.
|
||||||
|
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
// Catch documentation errors caused by code changes.
|
// Catch documentation errors caused by code changes.
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
|
|
||||||
|
@ -24,6 +25,10 @@ pub mod sapling;
|
||||||
pub mod sprout;
|
pub mod sprout;
|
||||||
|
|
||||||
#[cfg(any(feature = "local-prover", feature = "bundled-prover"))]
|
#[cfg(any(feature = "local-prover", feature = "bundled-prover"))]
|
||||||
|
#[cfg_attr(
|
||||||
|
docsrs,
|
||||||
|
doc(cfg(any(feature = "local-prover", feature = "bundled-prover")))
|
||||||
|
)]
|
||||||
pub mod prover;
|
pub mod prover;
|
||||||
|
|
||||||
// Circuit names
|
// Circuit names
|
||||||
|
@ -42,6 +47,7 @@ const DOWNLOAD_URL: &str = "https://download.z.cash/downloads";
|
||||||
|
|
||||||
/// Returns the default folder that the Zcash proving parameters are located in.
|
/// Returns the default folder that the Zcash proving parameters are located in.
|
||||||
#[cfg(feature = "directories")]
|
#[cfg(feature = "directories")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "directories")))]
|
||||||
pub fn default_params_folder() -> Option<PathBuf> {
|
pub fn default_params_folder() -> Option<PathBuf> {
|
||||||
BaseDirs::new().map(|base_dirs| {
|
BaseDirs::new().map(|base_dirs| {
|
||||||
if cfg!(any(windows, target_os = "macos")) {
|
if cfg!(any(windows, target_os = "macos")) {
|
||||||
|
@ -56,6 +62,7 @@ pub fn default_params_folder() -> Option<PathBuf> {
|
||||||
///
|
///
|
||||||
/// This mirrors the behaviour of the `fetch-params.sh` script from `zcashd`.
|
/// This mirrors the behaviour of the `fetch-params.sh` script from `zcashd`.
|
||||||
#[cfg(feature = "download-params")]
|
#[cfg(feature = "download-params")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))]
|
||||||
pub fn download_parameters() -> Result<(), minreq::Error> {
|
pub fn download_parameters() -> Result<(), minreq::Error> {
|
||||||
// Ensure that the default Zcash parameters location exists.
|
// Ensure that the default Zcash parameters location exists.
|
||||||
let params_dir = default_params_folder().ok_or(io::Error::new(
|
let params_dir = default_params_folder().ok_or(io::Error::new(
|
||||||
|
|
|
@ -49,6 +49,7 @@ impl LocalTxProver {
|
||||||
/// This function will panic if the paths do not point to valid parameter files with
|
/// This function will panic if the paths do not point to valid parameter files with
|
||||||
/// the expected hashes.
|
/// the expected hashes.
|
||||||
#[cfg(feature = "local-prover")]
|
#[cfg(feature = "local-prover")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "local-prover")))]
|
||||||
pub fn new(spend_path: &Path, output_path: &Path) -> Self {
|
pub fn new(spend_path: &Path, output_path: &Path) -> Self {
|
||||||
let (spend_params, spend_vk, output_params, _, _) =
|
let (spend_params, spend_vk, output_params, _, _) =
|
||||||
load_parameters(spend_path, output_path, None);
|
load_parameters(spend_path, output_path, None);
|
||||||
|
@ -81,6 +82,7 @@ impl LocalTxProver {
|
||||||
/// This function will panic if the parameters in the default local location do not
|
/// This function will panic if the parameters in the default local location do not
|
||||||
/// have the expected hashes.
|
/// have the expected hashes.
|
||||||
#[cfg(feature = "local-prover")]
|
#[cfg(feature = "local-prover")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "local-prover")))]
|
||||||
pub fn with_default_location() -> Option<Self> {
|
pub fn with_default_location() -> Option<Self> {
|
||||||
let params_dir = default_params_folder()?;
|
let params_dir = default_params_folder()?;
|
||||||
let (spend_path, output_path) = if params_dir.exists() {
|
let (spend_path, output_path) = if params_dir.exists() {
|
||||||
|
@ -103,6 +105,7 @@ impl LocalTxProver {
|
||||||
/// This requires the `bundled-prover` feature, which will increase the binary size by
|
/// This requires the `bundled-prover` feature, which will increase the binary size by
|
||||||
/// around 50 MiB.
|
/// around 50 MiB.
|
||||||
#[cfg(feature = "bundled-prover")]
|
#[cfg(feature = "bundled-prover")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "bundled-prover")))]
|
||||||
pub fn bundled() -> Self {
|
pub fn bundled() -> Self {
|
||||||
let (spend_buf, output_buf) = wagyu_zcash_parameters::load_sapling_parameters();
|
let (spend_buf, output_buf) = wagyu_zcash_parameters::load_sapling_parameters();
|
||||||
let (spend_params, spend_vk, output_params, _, _) =
|
let (spend_params, spend_vk, output_params, _, _) =
|
||||||
|
|
Loading…
Reference in New Issue