Skip to content

Commit

Permalink
update query hash calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Feb 28, 2024
1 parent 0aeaa87 commit 3a1ea8f
Showing 1 changed file with 51 additions and 34 deletions.
85 changes: 51 additions & 34 deletions credentialAtomicQueryV3OnChain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,21 @@ func TestAtomicQueryV3OnChainOutputs_Sig_CircuitUnmarshal(t *testing.T) {
out := new(AtomicQueryV3OnChainPubSignals)
err := out.PubSignalsUnmarshal([]byte(
`[
"26109404700696283154998654512117952420503675471097392618762221546565140481",
"21290882558588413185318640632869355965175070327539756875516642621267708162856",
"2943483356559152311923412925436024635269538717812859789851139200242297094",
"0",
"0",
"0",
"0",
"23",
"10",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"27918766665310231445021466320959318414450284884582375163563581940319453185",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"1642074362",
"1"
]`))
"26109404700696283154998654512117952420503675471097392618762221546565140481",
"1985992055626993205360700288228074716165415322842329919733176531545165024097",
"2943483356559152311923412925436024635269538717812859789851139200242297094",
"0",
"0",
"0",
"0",
"23",
"10",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"27918766665310231445021466320959318414450284884582375163563581940319453185",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"1642074362",
"1"
]`))
require.NoError(t, err)

expValue, err := PrepareCircuitArrayValues([]*big.Int{big.NewInt(10)}, 64)
Expand All @@ -237,14 +237,22 @@ func TestAtomicQueryV3OnChainOutputs_Sig_CircuitUnmarshal(t *testing.T) {
schema := it.CoreSchemaFromStr(t, "180410020913331409885634153623124536270")
slotIndex := 2
operator := 1
queryHash, err := poseidon.Hash([]*big.Int{
firstPartQueryHash, err := poseidon.Hash([]*big.Int{
schema.BigInt(),
big.NewInt(int64(slotIndex)),
big.NewInt(int64(operator)),
big.NewInt(0),
big.NewInt(1),
valueHash,
big.NewInt(1),
})
require.NoError(t, err)
queryHash, err := poseidon.Hash([]*big.Int{
firstPartQueryHash,
big.NewInt(int64(1)),
big.NewInt(int64(1)),
big.NewInt(0),
big.NewInt(0),
new(big.Int),
})
require.NoError(t, err)

Expand Down Expand Up @@ -278,21 +286,21 @@ func TestAtomicQueryV3OnChainOutputs_MTP_CircuitUnmarshal(t *testing.T) {
out := new(AtomicQueryV3OnChainPubSignals)
err := out.PubSignalsUnmarshal([]byte(
`[
"26109404700696283154998654512117952420503675471097392618762221546565140481",
"21290882558588413185318640632869355965175070327539756875516642621267708162856",
"2943483356559152311923412925436024635269538717812859789851139200242297094",
"0",
"0",
"0",
"1",
"23",
"10",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"27918766665310231445021466320959318414450284884582375163563581940319453185",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"1642074362",
"1"
]`))
"26109404700696283154998654512117952420503675471097392618762221546565140481",
"1985992055626993205360700288228074716165415322842329919733176531545165024097",
"2943483356559152311923412925436024635269538717812859789851139200242297094",
"0",
"0",
"0",
"1",
"23",
"10",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"27918766665310231445021466320959318414450284884582375163563581940319453185",
"20177832565449474772630743317224985532862797657496372535616634430055981993180",
"1642074362",
"1"
]`))
require.NoError(t, err)

expValue, err := PrepareCircuitArrayValues([]*big.Int{big.NewInt(10)}, 64)
Expand All @@ -302,14 +310,23 @@ func TestAtomicQueryV3OnChainOutputs_MTP_CircuitUnmarshal(t *testing.T) {
schema := it.CoreSchemaFromStr(t, "180410020913331409885634153623124536270")
slotIndex := 2
operator := 1
queryHash, err := poseidon.Hash([]*big.Int{

firstPartQueryHash, err := poseidon.Hash([]*big.Int{
schema.BigInt(),
big.NewInt(int64(slotIndex)),
big.NewInt(int64(operator)),
big.NewInt(0),
big.NewInt(1),
valueHash,
big.NewInt(1),
})
require.NoError(t, err)
queryHash, err := poseidon.Hash([]*big.Int{
firstPartQueryHash,
big.NewInt(int64(1)),
big.NewInt(int64(1)),
big.NewInt(0),
big.NewInt(0),
new(big.Int),
})

require.NoError(t, err)
Expand Down

0 comments on commit 3a1ea8f

Please sign in to comment.