2
2
3
3
pragma solidity ^ 0.8.0 ;
4
4
5
+ import {Signature} from "../types/Signature.sol " ;
5
6
import {uint128x2} from "../types/uint128x2.sol " ;
6
7
7
- struct Signature {
8
- bytes32 r;
9
- uint256 yParityAndS;
10
- }
11
-
12
- uint256 constant SIGNER_INFO_DEPOSIT_OFFSET = 64 ;
13
-
14
- uint256 constant SIGNER_INFO_END_TS_OFFSET = 112 ;
15
-
16
8
uint256 constant SIGNER_INFO_END_TS_MASK = uint256 (type (uint64 ).max) << 112 ;
17
9
18
- uint256 constant SIGNER_INFO_WITHDRAW_OFFSET = 176 ;
19
-
20
10
uint256 constant SIGNER_INFO_WITHDRAW_MASK = uint256 (type (uint48 ).max) << 176 ;
21
11
22
12
/**
@@ -27,27 +17,72 @@ uint256 constant SIGNER_INFO_WITHDRAW_MASK = uint256(type(uint48).max) << 176;
27
17
*/
28
18
type SignerInfo is uint256 ;
29
19
20
+ function SignerInfoFrom (uint256 _color , uint256 _deposit , uint256 _startTs ) pure returns (SignerInfo) {
21
+ return SignerInfo.wrap ((_color << 224 ) | (_deposit << 64 ) | _startTs);
22
+ }
23
+
30
24
function deposit (SignerInfo self ) pure returns (uint256 ) {
31
25
return uint48 (SignerInfo.unwrap (self) >> 64 );
32
26
}
33
27
34
- using {deposit} for SignerInfo global ;
28
+ function startTs (SignerInfo self ) pure returns (uint256 ) {
29
+ return uint64 (SignerInfo.unwrap (self));
30
+ }
31
+
32
+ function endTs (SignerInfo self ) pure returns (uint256 ) {
33
+ return uint64 (SignerInfo.unwrap (self) >> 112 );
34
+ }
35
35
36
- interface IDIDSigners {
37
- function authenticateExposureReportID3Sigs (
38
- bytes32 exposureReportID ,
39
- uint128x2 weightThresholdAndSignatureTs ,
40
- Signature[3 ] calldata sigs
41
- ) external view ;
36
+ function hasEndTs (SignerInfo self ) pure returns (bool ) {
37
+ return (SignerInfo.unwrap (self) & SIGNER_INFO_END_TS_MASK) != 0 ;
38
+ }
42
39
43
- function authenticateHumanID3Sigs (
40
+ function addEndTs (SignerInfo self , uint256 _endTs ) pure returns (SignerInfo) {
41
+ return SignerInfo.wrap (SignerInfo.unwrap (self) | (_endTs << 112 ));
42
+ }
43
+
44
+ function withdraw (SignerInfo self ) pure returns (uint256 ) {
45
+ return uint48 (SignerInfo.unwrap (self) >> 176 );
46
+ }
47
+
48
+ function addWithdraw (SignerInfo self , uint256 _withdraw ) pure returns (SignerInfo) {
49
+ return SignerInfo.wrap (SignerInfo.unwrap (self) | (_withdraw << 176 ));
50
+ }
51
+
52
+ function clearWithdraw (SignerInfo self ) pure returns (SignerInfo) {
53
+ return SignerInfo.wrap (SignerInfo.unwrap (self) & ~ SIGNER_INFO_WITHDRAW_MASK);
54
+ }
55
+
56
+ function color (SignerInfo self ) pure returns (uint256 ) {
57
+ return SignerInfo.unwrap (self) >> 224 ;
58
+ }
59
+
60
+ function isZero (SignerInfo self ) pure returns (bool ) {
61
+ return SignerInfo.unwrap (self) == 0 ;
62
+ }
63
+
64
+ using {
65
+ color,
66
+ withdraw,
67
+ addWithdraw,
68
+ clearWithdraw,
69
+ endTs,
70
+ addEndTs,
71
+ deposit,
72
+ startTs,
73
+ hasEndTs,
74
+ isZero
75
+ } for SignerInfo global ;
76
+
77
+ interface IDIDSigners {
78
+ function authenticateHumanIDv1 (
44
79
bytes32 exposureReportID ,
45
80
uint128x2 weightThresholdAndSignatureTs ,
46
81
bytes32 commitmentR ,
47
82
Signature[3 ] calldata sigs
48
83
) external view ;
49
84
50
- function authenticateHumanID5Sigs (
85
+ function authenticateHumanIDv1 (
51
86
bytes32 humanID ,
52
87
uint128x2 weightThresholdAndSignatureTs ,
53
88
bytes32 commitmentR ,
@@ -59,3 +94,7 @@ interface IDIDSigners {
59
94
*/
60
95
function signerInfo (address signer ) external view returns (SignerInfo);
61
96
}
97
+
98
+ interface IDIDSignersExposureReport {
99
+ function reportExposure (bytes32 exposureReportID , uint256 signatureTs , Signature[3 ] calldata sigs ) external ;
100
+ }
0 commit comments