Skip to content

Commit

Permalink
Remove unintended code updates for debugging
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
  • Loading branch information
jimthematrix committed Aug 27, 2024
1 parent fe446d9 commit f57d353
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 65 deletions.
2 changes: 0 additions & 2 deletions go-sdk/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/hyperledger/firefly-common v1.4.6 // indirect
github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e // indirect
github.com/iden3/wasmer-go v0.0.1 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
Expand All @@ -31,7 +30,6 @@ require (
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/tetratelabs/wazero v1.8.0 // indirect
github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/term v0.23.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go-sdk/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 h1:mkY6VDfwKVJc83QGKmwVXY2LYepi
github.com/iden3/go-rapidsnark/witness/v2 v2.0.0/go.mod h1:3JRjqUfW1hgI9hzLDO0v8z/DUkR0ZUehhYLlnIfRxnA=
github.com/iden3/go-rapidsnark/witness/wasmer v0.0.0-20230524142950-0986cf057d4e h1:lqrevdLsG1k8ieaxgUQccf3unf73m3zmkHJ3oIdld90=
github.com/iden3/go-rapidsnark/witness/wasmer v0.0.0-20230524142950-0986cf057d4e/go.mod h1:WUtPVKXrhfZHJXavwId2+8J/fKMHQ92N0MZDxt8sfEA=
github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e h1:WeiFCrpj5pLRtSA4Mg03yTrSZhHHqN/k5b6bwxd9/tY=
github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e/go.mod h1:UEBifEzw62T6VzIHJeHuUgeLg2U/J9ttf7hOwQEqnYk=
github.com/iden3/wasmer-go v0.0.1 h1:TZKh8Se8B/73PvWrcu+FTU9L1k5XYAmtFbioj7l0Uog=
github.com/iden3/wasmer-go v0.0.1/go.mod h1:ZnZBAO012M7o+Q1INXLRIxKQgEcH2FuwL0Iga8A4ufg=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
Expand Down Expand Up @@ -88,8 +86,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tetratelabs/wazero v1.8.0 h1:iEKu0d4c2Pd+QSRieYbnQC9yiFlMS9D+Jr0LsRmcF4g=
github.com/tetratelabs/wazero v1.8.0/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
Expand Down
61 changes: 2 additions & 59 deletions go-sdk/integration-test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/iden3/go-iden3-crypto/poseidon"
"github.com/iden3/go-rapidsnark/prover"
"github.com/iden3/go-rapidsnark/witness/v2"
"github.com/iden3/go-rapidsnark/witness/wazero"
"github.com/iden3/go-rapidsnark/witness/wasmer"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -68,7 +68,7 @@ func loadCircuit(circuitName string) (witness.Calculator, []byte, error) {

// create the calculator
var ops []witness.Option
ops = append(ops, witness.WithWasmEngine(wazero.NewCircom2WZWitnessCalculator))
ops = append(ops, witness.WithWasmEngine(wasmer.NewCircom2WitnessCalculator))
calc, err := witness.NewCalculator(wasmBytes, ops...)
if err != nil {
return nil, []byte{}, err
Expand Down Expand Up @@ -113,63 +113,6 @@ func testKeyFromKeyStorev3(t *testing.T) *keyscore.KeyEntry {
return key.NewKeyEntryFromPrivateKeyBytes([32]byte(keypair.PrivateKeyBytes()))
}

func TestProverConsistency(t *testing.T) {
calc, provingKey, err := loadCircuit("anon")
assert.NoError(t, err)
assert.NotNil(t, calc)

inputUTXO1, _ := new(big.Int).SetString("11105536912937084068928101349408965706972588455033352692020096509083673472621", 10)
inputUTXO2, _ := new(big.Int).SetString("15465388828766269815785883470037018081238967000866249029606878869544906338564", 10)
inputCommitments := []*big.Int{inputUTXO1, inputUTXO2}

inputSalt1, _ := new(big.Int).SetString("5927951837663929147166039603200937844121326272713394918469188222159202422582", 10)
inputSalt2, _ := new(big.Int).SetString("17917841137702758320228246776373303824065014972937096295347545011919429271965", 10)

inputOwnerPrivateKey, _ := new(big.Int).SetString("4809976146059268986656219153769057831564776846957203436108684914954577347309", 10)

outputUTXO1, _ := new(big.Int).SetString("20469276875056226243637792520323047315768980246096899186331579887313538888246", 10)
outputUTXO2 := big.NewInt(0)
outputCommitments := []*big.Int{outputUTXO1, outputUTXO2}

outputSalt1, _ := new(big.Int).SetString("15923997257752697586449902218798635762940021065988237105318697992049841356856", 10)
outputSalt2, _ := new(big.Int).SetString("15923997257752697586449902218798635762940021065988237105318697992049841356856", 10)

outputPubkeyX, _ := new(big.Int).SetString("21477999199190864914657682295281971958696083141431876494424306197238149067201", 10)
outputPubkeyY, _ := new(big.Int).SetString("12753061479492908706400125039783132140975068988201358996624310176395269704462", 10)

witnessInputs := map[string]interface{}{
"inputCommitments": inputCommitments,
"inputValues": []*big.Int{big.NewInt(15), big.NewInt(100)},
"inputSalts": []*big.Int{inputSalt1, inputSalt2},
"inputOwnerPrivateKey": inputOwnerPrivateKey,
"outputCommitments": outputCommitments,
"outputValues": []*big.Int{big.NewInt(115), big.NewInt(0)},
"outputSalts": []*big.Int{outputSalt1, outputSalt2},
"outputOwnerPublicKeys": [][]*big.Int{{outputPubkeyX, outputPubkeyY}, {big.NewInt(0), big.NewInt(0)}},
}

witness, err := calc.CalculateWitness(witnessInputs, true)
assert.NoError(t, err)
fmt.Println(witness[0:20])

// calculate the witness object for checking correctness
witnessBin, err := calc.CalculateWTNSBin(witnessInputs, true)
assert.NoError(t, err)
assert.NotNil(t, witnessBin)

proof, err := prover.Groth16Prover(provingKey, witnessBin)
assert.NoError(t, err)
fmt.Println(proof.Proof)
assert.Equal(t, proof.Proof.A[0], "17982378101734411650905789560168412932368408844442288523095988179134755465737")
assert.Equal(t, proof.Proof.A[1], "3040175445574015287839617961397409686830019142290991743734882314707753447001")
assert.Equal(t, proof.Proof.B[0][0], "15203037490185862740834477451295620375272207531204659524273033744748202047241")
assert.Equal(t, proof.Proof.B[0][1], "6042961882591882687885932555150527019702606234316463466126680852960731647695")
assert.Equal(t, proof.Proof.B[1][0], "4137329889383146102595850132435331470464205035767242489014075696987798549876")
assert.Equal(t, proof.Proof.B[1][1], "21380798455802861112032749748563632949682646762936491546492019402111191478447")
assert.Equal(t, proof.Proof.C[0], "5873412255570044323099744150476785824238225238207905605375256773674623181487")
assert.Equal(t, proof.Proof.C[1], "2844618734247625581112041391396058912201053703359532829725048784693968941382")
}

func TestZeto_1_SuccessfulProving(t *testing.T) {
calc, provingKey, err := loadCircuit("anon")
assert.NoError(t, err)
Expand Down

0 comments on commit f57d353

Please sign in to comment.