Skip to content

Commit

Permalink
refactoring, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
olegfomenko committed May 16, 2024
1 parent d41a43e commit 0b736f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pub mod wnla;
pub mod circuit;
pub(crate) mod transcript;
pub mod transcript;
pub mod range_proof;

mod util;
Expand Down
3 changes: 2 additions & 1 deletion src/range_proof/reciprocal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ impl ReciprocalRangeProofProtocol {
}

/// Creates circuit parameters based on provided challenge. For the same challenge will generate same parameters.
fn make_circuit(&self, e: Scalar) -> ArithmeticCircuit<impl Fn(PartitionType, usize) -> Option<usize> + '_>
#[inline(always)]
pub fn make_circuit(&self, e: Scalar) -> ArithmeticCircuit<impl Fn(PartitionType, usize) -> Option<usize> + '_>
{
let dim_nm = self.dim_nd;
let dim_no = self.dim_np;
Expand Down
6 changes: 3 additions & 3 deletions src/range_proof/u64_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::range_proof::reciprocal::{Proof, ReciprocalRangeProofProtocol, Witnes
#[allow(dead_code)]
const G_VEC_CIRCUIT_SZ: usize = 16;
pub const G_VEC_FULL_SZ: usize = 16;
const H_VEC_CIRCUIT_SZ: usize = 26;
pub const H_VEC_CIRCUIT_SZ: usize = 26;
pub const H_VEC_FULL_SZ: usize = 32;


Expand All @@ -29,9 +29,9 @@ pub struct U64RangeProofProtocol {

impl U64RangeProofProtocol {
/// Count of digits of u64 in hex representation.
const DIM_ND: usize = 16;
pub const DIM_ND: usize = 16;
/// Base (hex)
const DIM_NP: usize = 16;
pub const DIM_NP: usize = 16;

/// Creates commitment for the private value and blinding: `commitment = x*g + s*h_vec[0]`
pub fn commit_value(&self, x: u64, s: &Scalar) -> ProjectivePoint {
Expand Down
7 changes: 4 additions & 3 deletions src/transcript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use k256::elliptic_curve::group::GroupEncoding;
use k256::elliptic_curve::PrimeField;
use merlin::Transcript;


pub(crate) fn app_point(label: &'static [u8], p: &ProjectivePoint, t: &mut Transcript) {
#[inline]
pub fn app_point(label: &'static [u8], p: &ProjectivePoint, t: &mut Transcript) {
t.append_message(label, p.to_bytes().as_slice());
}

pub(crate) fn get_challenge(label: &'static [u8], t: &mut Transcript) -> Scalar {
#[inline]
pub fn get_challenge(label: &'static [u8], t: &mut Transcript) -> Scalar {
let mut buf = [0u8; 32];
t.challenge_bytes(label, &mut buf);
Scalar::from_repr(*FieldBytes::from_slice(&buf)).unwrap()
Expand Down

0 comments on commit 0b736f8

Please sign in to comment.