-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use precomputation for default commitments (#136)
This work adds precomputation support for Pedersen commitments that use a provided generator. Basepoint tables are created via `lazy_static` alongside the generators themselves. When computing a commitment using the default generators, the corresponding tables are used. Commitments using any other generators are unchanged. Closes [issue #135](#135).
- Loading branch information
1 parent
532ccc0
commit acdcee6
Showing
4 changed files
with
69 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019. The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
use std::time::Duration; | ||
|
||
use criterion::{criterion_group, Criterion}; | ||
use rand::thread_rng; | ||
use tari_crypto::{ | ||
commitment::HomomorphicCommitmentFactory, | ||
keys::SecretKey, | ||
ristretto::{ | ||
pedersen::commitment_factory::PedersenCommitmentFactory, | ||
RistrettoSecretKey, | ||
}, | ||
}; | ||
|
||
pub fn commit_default(c: &mut Criterion) { | ||
let factory = PedersenCommitmentFactory::default(); | ||
let mut rng = thread_rng(); | ||
|
||
c.bench_function("commit_default key pair", |b| { | ||
// Commitment value and mask | ||
let v = RistrettoSecretKey::random(&mut rng); | ||
let m = RistrettoSecretKey::random(&mut rng); | ||
b.iter(|| factory.commit(&m, &v)); | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
name = commitment; | ||
config = Criterion::default().warm_up_time(Duration::from_millis(500)); | ||
targets = commit_default | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters