cargodog / arcturus

A pure rust implementation of Arcturus proofs for confidential transactions.
MIT License
12 stars 2 forks source link

Proof error #40

Closed Fiono11 closed 3 years ago

Fiono11 commented 3 years ago

I tried to make an example based on yours, but it gives me a proof error. Can you tell me why, please? Thanks!

use arcturus::*;
use curve25519_dalek::ristretto::RistrettoPoint;
use curve25519_dalek::scalar::Scalar;
use merlin::Transcript;
use rand::rngs::OsRng;
use curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT;

pub const G: RistrettoPoint = RISTRETTO_BASEPOINT_POINT;

fn main() {

    let mut rng = OsRng;

    let gens = ArcturusGens::new(2, 2, 1).unwrap();

    let mut ring: Vec<Output> = Vec::new();

    let sk = Scalar::random(&mut rng);
    let blind = Scalar::random(&mut rng);

    ring.push(Output::new(sk*G, Scalar::from(5u64)*G + blind*G));
    ring.push(Output::new(Scalar::random(&mut rng)*G, Scalar::random(&mut rng)*G));
    ring.push(Output::new(Scalar::random(&mut rng)*G, Scalar::random(&mut rng)*G));
    ring.push(Output::new(Scalar::random(&mut rng)*G, Scalar::random(&mut rng)*G));

    // Indices of UTXOs to spend as transaction inputs
    let idxs = vec![0];

    // Secret data to spend each input UTXO
    let spends = vec![SpendSecret::new(sk, 5, blind)];

    // Secret data for new minted outputs (Total mint ammounts must balance total input ammounts).
    let mints = vec![MintSecret::new(Scalar::random(&mut rng)*G, 5, Scalar::random(&mut rng))];

    // Signer computes the transaction proof
    let mut t = Transcript::new(b"Test proof");
    let proof = gens.prove(&mut t, &ring[..], &idxs[..], &spends[..], &mints[..]).unwrap();

    // The verifier my verify the proof as follows:
    let mut t = Transcript::new(b"Test proof");
    //let proofs = vec![proof];
    assert!(gens.verify(&mut t, &ring[..], proof).is_ok());

}
Fiono11 commented 3 years ago

Nvm, found out! Thanks for this crate btw!

cargodog commented 3 years ago

I think my docs examples are outdated. I should update them. Glad you got it working! Feel free to make suggestions or log issues if you run into difficulties :)