提问人:fabriziogianni7 提问时间:9/14/2023 更新时间:9/14/2023 访问量:47
为什么 Circuit (circom) 无法比较时间戳?
Why Circuit (circom) can't compare timestamp?
问:
我有这个电路,我想比较 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();
答:
0赞
fabriziogianni7
9/14/2023
#1
需要更改 gre 的参数:变成component greaterEqThan = GreaterEqThan(8);
component greaterEqThan = GreaterEqThan(64);
评论