|
|
@ -196,24 +196,25 @@ func (c *Client) ABCIQueryWithOptions(ctx context.Context, path string, data tmb |
|
|
|
} |
|
|
|
|
|
|
|
// Validate the value proof against the trusted header.
|
|
|
|
if resp.Value != nil { |
|
|
|
// 1) build a Merkle key path from path and resp.Key
|
|
|
|
if c.keyPathFn == nil { |
|
|
|
return nil, errors.New("please configure Client with KeyPathFn option") |
|
|
|
} |
|
|
|
|
|
|
|
kp, err := c.keyPathFn(path, resp.Key) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("can't build merkle key path: %w", err) |
|
|
|
} |
|
|
|
// build a Merkle key path from path and resp.Key
|
|
|
|
if c.keyPathFn == nil { |
|
|
|
return nil, errors.New("please configure Client with KeyPathFn option") |
|
|
|
} |
|
|
|
|
|
|
|
// 2) verify value
|
|
|
|
kp, err := c.keyPathFn(path, resp.Key) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("can't build merkle key path: %w", err) |
|
|
|
} |
|
|
|
|
|
|
|
// verify value
|
|
|
|
if resp.Value != nil { |
|
|
|
err = c.prt.VerifyValue(resp.ProofOps, l.AppHash, kp.String(), resp.Value) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("verify value proof: %w", err) |
|
|
|
} |
|
|
|
} else { // OR validate the absence proof against the trusted header.
|
|
|
|
err = c.prt.VerifyAbsence(resp.ProofOps, l.AppHash, string(resp.Key)) |
|
|
|
err = c.prt.VerifyAbsence(resp.ProofOps, l.AppHash, kp.String()) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("verify absence proof: %w", err) |
|
|
|
} |
|
|
|