为什么Circuit(circom)无法比较时间戳?

问题描述 投票:0回答:1

我有这个电路,我想比较 2 个时间戳。

如果我尝试使用较小的数字,它可以工作,如果我尝试使用时间戳,它就不起作用。

这是电路(.circom)

    pragma circom 2.0.0;

include "../node_modules/circomlib/circuits/comparators.circom";
include "../node_modules/circomlib/circuits/poseidon.circom";

template drivingLicenseConstraint() {
    // public
    signal input hashData; //input: is the hash we have in the SBT. is the hash of the hash of every data poseidon.hashData
    signal input ownerAddress;
    signal input threshold; // threshold: now timestamp, current time. it should be less than expiry date

    // private
    // idToSBTData[tokenId].encryptedIssuanceDate,
    // idToSBTData[tokenId].encryptedExpiryeDate,
    // idToSBTData[tokenId].encryptedOwnerName,
    // idToSBTData[tokenId].encryptedLicenseNumber,
    // idToSBTData[tokenId].encryptedLicenseType

    signal input expiryDate;

    // true/false
    signal output out;

    // check hash to be equal to hashData
    component hash = Poseidon(2);
    hash.inputs[0] <== ownerAddress;
    hash.inputs[1] <== expiryDate;
    hashData === hash.out;

    // check driving license is not expired
    // expiryDate should be bigger than current time in order to return true
    component greaterEqThan = GreaterEqThan(8); 
    greaterEqThan.in[0] <== expiryDate;
    greaterEqThan.in[1] <== threshold;

    out <-- greaterEqThan.out;
    out === 1;
}

component main {public [hashData,ownerAddress,threshold]} = drivingLicenseConstraint();
cryptography sbt circuit circom
1个回答
0
投票

需要更改gre的参数:

component greaterEqThan = GreaterEqThan(8);
变成

component greaterEqThan = GreaterEqThan(64);

参数是输入的位数https://github.com/iden3/circomlib/blob/cff5ab6288b55ef23602221694a6a38a0239dcc0/ Circuits/comparators.circom#L117C1-L127C2

© www.soinside.com 2019 - 2024. All rights reserved.