rust-secp256k1-zkp breaking changes to support (#155)

Rewinding range proofs to recover transaction value from outputs
This commit is contained in:
AntiochP
2017-10-05 17:40:46 -04:00
committed by Ignotus Peverell
parent ea632076bd
commit e060b1953e
6 changed files with 124 additions and 15 deletions
+11 -7
View File
@@ -248,23 +248,27 @@ pub fn transaction_identifier(tx: &core::transaction::Transaction) -> core::hash
#[cfg(test)]
mod tests {
use super::*;
use secp::{Secp256k1, ContextFlag};
use secp::key;
use secp;
use keychain::Keychain;
#[test]
fn test_add_entry() {
let ec = Secp256k1::with_caps(ContextFlag::Commit);
let keychain = Keychain::from_random_seed().unwrap();
let pk1 = keychain.derive_pubkey(1).unwrap();
let pk2 = keychain.derive_pubkey(2).unwrap();
let pk3 = keychain.derive_pubkey(3).unwrap();
let output_commit = ec.commit_value(70).unwrap();
let output_commit = keychain.commit(70, &pk1).unwrap();
let inputs = vec![
core::transaction::Input(ec.commit_value(50).unwrap()),
core::transaction::Input(ec.commit_value(25).unwrap()),
core::transaction::Input(keychain.commit(50, &pk2).unwrap()),
core::transaction::Input(keychain.commit(25, &pk3).unwrap()),
];
let msg = secp::pedersen::ProofMessage::empty();
let outputs = vec![
core::transaction::Output {
features: core::transaction::DEFAULT_OUTPUT,
commit: output_commit,
proof: ec.range_proof(0, 100, key::ZERO_KEY, output_commit, ec.nonce()),
proof: keychain.range_proof(100, &pk1, output_commit, msg).unwrap(),
},
];
let test_transaction = core::transaction::Transaction::new(inputs, outputs, 5);
+5 -2
View File
@@ -561,6 +561,7 @@ mod tests {
use types::*;
use core::core::build;
use blockchain::{DummyChain, DummyChainImpl, DummyUtxoSet};
use secp;
use keychain::Keychain;
use std::sync::{Arc, RwLock};
use blake2;
@@ -1074,7 +1075,8 @@ mod tests {
let keychain = keychain_for_tests();
let pubkey = keychain.derive_pubkey(value as u32).unwrap();
let commit = keychain.commit(value, &pubkey).unwrap();
let proof = keychain.range_proof(value, &pubkey, commit).unwrap();
let msg = secp::pedersen::ProofMessage::empty();
let proof = keychain.range_proof(value, &pubkey, commit, msg).unwrap();
transaction::Output {
features: transaction::DEFAULT_OUTPUT,
@@ -1088,7 +1090,8 @@ mod tests {
let keychain = keychain_for_tests();
let pubkey = keychain.derive_pubkey(value as u32).unwrap();
let commit = keychain.commit(value, &pubkey).unwrap();
let proof = keychain.range_proof(value, &pubkey, commit).unwrap();
let msg = secp::pedersen::ProofMessage::empty();
let proof = keychain.range_proof(value, &pubkey, commit, msg).unwrap();
transaction::Output {
features: transaction::COINBASE_OUTPUT,