Skip to content

Commit 95a67d0

Browse files
authored
Create constant_time.hcs
1 parent 30f6522 commit 95a67d0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fun constant_time_eq(a: List<Int>, b: List<Int>) -> Int [
2+
if a.len() != b.len() [
3+
end 0
4+
]
5+
let diff = 0
6+
let i = 0
7+
while i < a.len() [
8+
if a[i] != b[i] [
9+
diff = diff + 1
10+
]
11+
i = i + 1
12+
]
13+
if diff == 0 [
14+
end 1
15+
]
16+
end 0
17+
]

0 commit comments

Comments
 (0)