Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs improvements #602

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl EncKey {
// generate an ephemeral key pair as the virtual sender to derive the crypto box
let ephemeral_keypair = crypto_kx::Keypair::generate(&mut rng);
// `crypto_kx` generates a pair of shared secrets, see <https://libsodium.gitbook.io/doc/key_exchange>
// we use the transimission key of the ephemeral sender (equals to the receiving
// we use the transmission key of the ephemeral sender (equals to the receiving
// key of the server) as the shared secret.
let shared_secret = ephemeral_keypair.session_keys_to(&self.0).tx;
let cipher = XChaCha20Poly1305::new(shared_secret.as_ref().into());
Expand Down Expand Up @@ -179,7 +179,7 @@ impl KeyPair {
}

/// Decrypt a ciphertext with authenticated associated data provided.
/// If the associated data is different that that used during encryption,
/// If the associated data is different from that used during encryption,
/// then decryption will fail.
pub fn decrypt(&self, ciphertext: &Ciphertext, aad: &[u8]) -> Result<Vec<u8>, AEADError> {
let shared_secret = crypto_kx::Keypair::from(self.dec_key.0.clone())
Expand Down
2 changes: 1 addition & 1 deletion commitment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait CommitmentScheme {
r: Option<&Self::Randomness>,
) -> Result<Self::Output, Self::Error>;

/// Verify algorithm that output `Ok` if accepted, or `Err` if rejected.
/// Verify the algorithm that outputs `Ok` if accepted, or `Err` if rejected.
fn verify<T: Borrow<Self::Input>>(
input: T,
r: Option<&Self::Randomness>,
Expand Down
4 changes: 2 additions & 2 deletions elgamal/src/gadgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ where
/// in each call, and the nonce is initialized to zero.
/// * `key_var` - variables corresponding to the symmetric key
/// * `data_vars` - the variables for the data to be encrypted. The format
/// of this input is a list of variable of arbitrary length
/// of this input is a list of variables of arbitrary length
/// * `returns` - the variables that map to the ciphertext contents. The
/// output size is the same as the length of data_vars
fn apply_counter_mode_stream(
Expand Down Expand Up @@ -166,7 +166,7 @@ where
F: PrimeField,
P: TECurveConfig<BaseField = F>,
{
/// Compute the gadget that check a correct Elgamal encryption
/// Compute the gadget that checks a correct Elgamal encryption
/// * `pk_vars` - variables corresponding to the encryption public key
/// * `data_vars` - variables corresponding to the plaintext. Can be of
/// arbitrary length.
Expand Down
2 changes: 1 addition & 1 deletion merkle_tree/src/append_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ mod mt_tests {
assert!(mt.forget(1).expect_ok().is_ok());
// Number of leaves shall not change
assert_eq!(mt.num_leaves(), 3);
// Leaves that are forgotten doesn't appear here
// Leaves that are forgotten don't appear here
let leaves = mt.into_iter().collect::<Vec<_>>();
assert_eq!(leaves, [(0, F::from(0u64)), (2, F::from(2u64))]);

Expand Down
4 changes: 2 additions & 2 deletions merkle_tree/src/gadgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub struct Merkle3AryNodeVar {
/// Circuit variable for a Merkle non-membership proof of a 3-ary Merkle tree.
/// Contains:
/// * a list of node variables in the path,
/// * a variable correseponsing to the position of the element.
/// * a variable corresponding to the position of the element.
#[derive(Debug, Clone)]
pub struct Merkle3AryNonMembershipProofVar {
node_vars: Vec<Merkle3AryNodeVar>,
Expand All @@ -245,7 +245,7 @@ pub struct Merkle3AryNonMembershipProofVar {
/// Circuit variable for a Merkle proof of a 3-ary Merkle tree.
/// Contains:
/// * a list of node variables in the path,
/// * a variable correseponsing to the value of the element.
/// * a variable corresponding to the value of the element.
#[derive(Debug, Clone)]
pub struct Merkle3AryMembershipProofVar {
node_vars: Vec<Merkle3AryNodeVar>,
Expand Down
2 changes: 1 addition & 1 deletion merkle_tree/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ where
/// A merkle path is a bottom-up list of nodes from leaf to the root.
pub type MerklePath<E, I, T> = Vec<MerkleNode<E, I, T>>;

/// A merkle commitment consists a root hash value, a tree height and number of
/// A merkle commitment consists of a root hash value, a tree height and number of
/// leaves
#[derive(
Eq,
Expand Down
8 changes: 4 additions & 4 deletions merkle_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where
fn digest_leaf(pos: &I, elem: &E) -> Result<T, MerkleTreeError>;
}

/// An trait for Merkle tree index type.
/// A trait for Merkle tree index type.
pub trait ToTraversalPath<const ARITY: usize> {
/// Convert the given index to a vector of branch indices given tree height
/// and ARITY.
Expand Down Expand Up @@ -183,7 +183,7 @@ pub trait MerkleCommitment<T: NodeValue>:
}

/// Basic functionalities for a merkle tree implementation. Abstracted as an
/// accumulator for fixed-length array. Supports generate membership proof at a
/// accumulator for fixed-length array. Supports generating membership proof at a
/// given position and verify a membership proof.
pub trait MerkleTreeScheme: Sized {
/// Merkle tree element type
Expand Down Expand Up @@ -243,7 +243,7 @@ pub trait MerkleTreeScheme: Sized {
// ) -> Result<(), MerkleTreeError>;

/// Return an iterator that iterates through all element that are not
/// forgetton
/// forgotten
fn iter(&self) -> MerkleTreeIter<Self::Element, Self::Index, Self::NodeValue>;
}

Expand Down Expand Up @@ -272,7 +272,7 @@ pub trait AppendableMerkleTreeScheme: MerkleTreeScheme<Index = u64> {
}

/// A universal merkle tree is abstracted as a random-access array or a
/// key-value map. It allows manipulation at any given position, and has ability
/// key-value map. It allows manipulation at any given position, and has the ability
/// to generate/verify a non-membership proof.
pub trait UniversalMerkleTreeScheme: MerkleTreeScheme {
/// Non membership proof for a given index
Expand Down
2 changes: 1 addition & 1 deletion merkle_tree/src/light_weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ where
H: DigestAlgorithm<E, u64, T>,
T: NodeValue,
{
/// Construct a new Merkle tree with given height from a data slice
/// Construct a new Merkle tree with a given height from a data slice
/// * `height` - height of the Merkle tree, if `None`, it will calculate the
/// minimum height that could hold all elements.
/// * `elems` - an iterator to all elements
Expand Down
2 changes: 1 addition & 1 deletion merkle_tree/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ macro_rules! impl_merkle_tree_scheme {
};
}

/// Macro for generating a forgetable merkle tree implementation
/// Macro for generating a forgettable merkle tree implementation
#[macro_export]
macro_rules! impl_forgetable_merkle_tree_scheme {
($name: ident) => {
Expand Down
2 changes: 1 addition & 1 deletion merkle_tree/src/namespaced_merkle_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ where
T: NodeValue,
N: Namespace,
{
/// Initializze an empty NMT
/// Initialize an empty NMT
pub fn new(height: usize) -> Self {
let namespace_ranges: BTreeMap<N, Range<u64>> = BTreeMap::new();
let inner = InnerTree::<E, H, T, N, ARITY>::new(height);
Expand Down
4 changes: 2 additions & 2 deletions pcs/src/multilinear_kzg/batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ use ark_std::{end_timer, format, start_timer, string::ToString, vec, vec::Vec};
/// - the prover parameters for multilinear KZG,
/// - a list of MLEs,
/// - a batch commitment to all MLEs
/// - and a same number of points,
/// - and the same number of points,
/// compute a batch opening for all the polynomials.
///
/// For simplicity, this API requires each MLE to have only one point. If
/// the caller wish to use more than one points per MLE, it should be
/// the caller wishes to use more than one point per MLE, it should be
/// handled at the caller layer.
///
/// Returns an error if the lengths do not match.
Expand Down
6 changes: 3 additions & 3 deletions pcs/src/multilinear_kzg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<E: Pairing> PolynomialCommitmentScheme for MultilinearKzgPCS<E> {
///
/// This function takes 2^{num_var +1} number of scalar multiplications over
/// G1:
/// - it prodceeds with `num_var` number of rounds,
/// - it proceeds with `num_var` number of rounds,
/// - at round i, we compute an MSM for `2^{num_var - i + 1}` number of G2
/// elements.
fn open(
Expand All @@ -197,11 +197,11 @@ impl<E: Pairing> PolynomialCommitmentScheme for MultilinearKzgPCS<E> {
/// - the prover parameters for multilinear KZG,
/// - a list of polynomials,
/// - a (batch) commitment to all polynomials,
/// - and a same number of points,
/// - and the same number of points,
/// compute a batch opening for all the polynomials.
///
/// For simplicity, this API requires each MLE to have only one point. If
/// the caller wish to use more than one points per MLE, it should be
/// the caller wish to use more than one point per MLE, it should be
/// handled at the caller layer.
///
/// Returns an error if the lengths do not match.
Expand Down
4 changes: 2 additions & 2 deletions pcs/src/multilinear_kzg/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub(crate) fn get_uni_domain<F: PrimeField>(
/// Given an MLE W, and a list of univariate polynomials l, generate the
/// univariate polynomial that composes W with l.
///
/// Returns an error if l's length does not matches number of variables in W.
/// Returns an error if l's length does not matches the number of variables in W.
pub(crate) fn compute_w_circ_l<F: PrimeField>(
w: &DenseMultilinearExtension<F>,
l: &[DensePolynomial<F>],
Expand Down Expand Up @@ -130,7 +130,7 @@ pub fn get_batched_nv(num_var: usize, polynomials_len: usize) -> usize {
}

/// merge a set of polynomials. Returns an error if the
/// polynomials do not share a same number of nvs.
/// polynomials do not share the same number of nvs.
pub fn merge_polynomials<F: PrimeField>(
polynomials: &[MLE<F>],
) -> Result<DenseMultilinearExtension<F>, PCSError> {
Expand Down
2 changes: 1 addition & 1 deletion pcs/src/univariate_kzg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<E: Pairing> PolynomialCommitmentScheme for UnivariateKzgPCS<E> {
Ok((Self::Proof { proof }, eval))
}

/// Input a list of polynomials, and a same number of points,
/// Input a list of polynomials, and the same number of points,
/// compute a multi-opening for all the polynomials.
// This is a naive approach
// TODO: to implement the more efficient batch opening algorithm
Expand Down
Loading