Skip to content

Commit 37c7bf9

Browse files
committed
spec security: add missing operators
1 parent dd33c2f commit 37c7bf9

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

proof/spec/extra/SpecSecurity.ec

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,57 @@
11
require import AllCore List Distr DList.
2+
require import BitEncoding.
3+
(*---*) import BitChunking.
4+
25
from Jasmin require import JModel.
36

47
require (****) XMSS_TW.
58
require import XMSS_PRF.
69
import Params Types XMSS_Types Hash WOTS Address LTree BaseW.
710

11+
import FL_XMSS_TW SA WTW.
12+
13+
14+
op BitsToBytes (bits : bool list) : W8.t list = map W8.bits2w (chunk W8.size bits).
15+
op BytesToBits (bytes : W8.t list) : bool list = flatten (map W8.w2bits bytes).
16+
op W64toBytes_ext (x : W64.t) (l : int) : W8.t list =
17+
rev (mkseq (fun i => nth W8.zero (to_list (W8u8.unpack8 x)) i) l).
18+
819
(* Get checksum from XMXX_Checksum and then plug those results
920
here *)
1021

11-
(*
1222
clone import XMSS_TW as XMSS_ABSTRACT with
1323
type mseed <- nbytes,
14-
op dmseed <- (dmap ((dlist W8.dword n)) NBytes.insubd),
24+
op dmseed <- (dmap ((dlist W8.dword Params.n)) NBytes.insubd),
1525
type mkey <- nbytes * int,
16-
type FLXMSSTWL.SA.WTW.pseed <- nbytes,
17-
op FLXMSSTWL.SA.WTW.dpseed <- (dmap ((dlist W8.dword n)) NBytes.insubd),
18-
type FLXMSSTWL.SA.WTW.sseed <- nbytes,
19-
op FLXMSSTWL.SA.WTW.dsseed <- (dmap ((dlist W8.dword n)) NBytes.insubd),
20-
type FLXMSSTWL.SA.WTW.adrs <- adrs,
21-
type msgXMSSTW <- W8.t list,
22-
op FLXMSSTWL.n <- n,
23-
op FLXMSSTWL.h <- h,
24-
op mkg = (fun (ms : nbytes) (i : FLXMSSTWL.SA.index) =>
25-
let padding = lenbytes_be64 prf_padding_val padding_len in
26-
let in_0 = lenbytes_be32 (W32.of_int (FLXMSSTWL.SA.Index.val i)) 4 in
27-
(Hash (padding ++ val ms ++ in_0),FLXMSSTWL.SA.Index.val i)).
26+
type msgXMSSTW <- W8.t list.
27+
28+
(*
29+
type FL_XMSS_TW.SA.WTW.pseed <- nbytes,
30+
op FL_XMSS_TW.SA.WTW.dpseed <- (dmap ((dlist W8.dword n)) NBytes.insubd),
31+
type FL_XMSS_TW.SA.WTW.sseed <- nbytes,
32+
op FL_XMSS_TW.SA.WTW.dsseed <- (dmap ((dlist W8.dword n)) NBytes.insubd),
33+
type FL_XMSS_TW.SA.WTW.adrs <- adrs,
34+
op FL_XMSS_TW.n <- n,
35+
op FL_XMSS_TW.h <- h,
36+
op mkg = (fun (ms : nbytes) (i : FL_XMSS_TW.SA.index) =>
37+
let padding = W64toBytes_ext prf_padding_val padding_len in
38+
let in_0 = toByte (W32.of_int (FL_XMSS_TW.SA.Index.val i)) 4 in
39+
(Hash (padding ++ val ms ++ in_0),FL_XMSS_TW.SA.Index.val i)).
40+
*)
2841
print XMSS_TW.
2942

30-
import FLXMSSTWL SA WTW.
43+
44+
3145
import HtS Repro MCORO.
3246

3347
module FakeRO : POracle = {
3448
var root : nbytes
3549

3650
proc o(x : (nbytes * int) * W8.t list) : msgFLXMSSTW = {
3751
var t,idx_bytes;
38-
idx_bytes <- lenbytes_be32 (W32.of_int x.`1.`2) 4;
39-
t <- (ThreeNBytesBytes.insubd (val x.`1.`1 ++ val root ++ idx_bytes));
40-
return DigestBlock.insubd (BytesToBits (val (H_msg t x.`2)));
52+
idx_bytes <- toByte (W32.of_int x.`1.`2) 4;
53+
t <- (ThreeNBytesBytes.insubd (NBytes.val x.`1.`1 ++ NBytes.val root ++ idx_bytes));
54+
return DigestBlock.insubd (BytesToBits (NBytes.val (H_msg t x.`2)));
4155
}
4256
}.
4357

@@ -66,7 +80,7 @@ op sigrel(asig : sigXMSSTW, sig : sig_t) =
6680
(* asig.`1 = ??? /\ why is the public seed in the signature ? *)
6781
asig.`1.`1 = sig.`r /\
6882
asig.`1.`2 = to_uint sig.`sig_idx /\
69-
asig.`2.`1 = FLXMSSTWL.SA.Index.insubd (to_uint sig.`sig_idx) /\
83+
asig.`2.`1 = FL_XMSS_TW.SA.Index.insubd (to_uint sig.`sig_idx) /\
7084
asig.`2.`2 = DBLL.insubd
7185
(map (fun (b : nbytes) => DigestBlock.insubd (BytesToBits (NBytes.val b))) (val sig.`r_sig.`1)) /\
7286
asig.`2.`3 = DBHL.insubd
@@ -82,5 +96,3 @@ equiv ver_eq : XMSS_TW(FakeRO).verify ~ XMSS_PRF.verify : pkrel pk{1} pk{2} /\ =
8296
={res}.
8397
proc.
8498
admitted.
85-
86-
*)

0 commit comments

Comments
 (0)