@@ -8,7 +8,7 @@ class Signatures extends Struct({
8
8
9
9
class HumanIDWitness extends MerkleWitness ( 16 ) { }
10
10
11
- const requireUnique = ( treeRoot : State < Field > , witness : HumanIDWitness ) => {
11
+ const addToMerkleTree = ( treeRoot : State < Field > , witness : HumanIDWitness ) => {
12
12
const currentTreeRoot = treeRoot . getAndRequireEquals ( ) ;
13
13
currentTreeRoot . assertEquals (
14
14
witness . calculateRoot ( Field ( 0 ) ) ,
@@ -17,11 +17,35 @@ const requireUnique = (treeRoot: State<Field>, witness: HumanIDWitness) => {
17
17
treeRoot . set ( witness . calculateRoot ( Field ( 1 ) ) ) ;
18
18
}
19
19
20
- const authenticate = ( humanIDv1 : Field , sigs : Signatures , truncatedHumanID : Field ) => {
20
+ const authenticate = ( humanIDv1 : Field , sigs : Signatures ) => {
21
21
// TODO(KimlikDAO-bot)
22
22
return true ;
23
23
}
24
24
25
25
const EmptyRoot = Field ( 0xccdd9994da4ffb1d39fcdf50d2c2c6240c423d6ec332865eea991c7bf1e5a9cn ) ;
26
26
27
- export { EmptyRoot , HumanIDWitness , Signatures , authenticate , requireUnique } ;
27
+ const requireConsistent = ( humanIDv1 : Field , truncatedHumanIDv1 : Field ) => {
28
+ humanIDv1 . sub ( truncatedHumanIDv1 ) . div ( 65536 )
29
+ . assertLessThan ( ( 1n << 238n ) + 0x224698fc094cf91b992d30ed0000n ) ;
30
+ }
31
+
32
+ const acceptHumanIDv1 = (
33
+ humanIDv1 : Field ,
34
+ sigs : Signatures ,
35
+ treeRoot : State < Field > ,
36
+ witness : HumanIDWitness
37
+ ) => {
38
+ authenticate ( humanIDv1 , sigs ) ;
39
+ requireConsistent ( humanIDv1 , witness . calculateIndex ( ) ) ;
40
+ addToMerkleTree ( treeRoot , witness ) ;
41
+ }
42
+
43
+ export {
44
+ EmptyRoot ,
45
+ HumanIDWitness ,
46
+ Signatures ,
47
+ acceptHumanIDv1 ,
48
+ addToMerkleTree ,
49
+ authenticate ,
50
+ requireConsistent
51
+ } ;
0 commit comments