Skip to content

Commit 2ad918d

Browse files
committed
Add SST impl
1 parent 568655d commit 2ad918d

22 files changed

+1265
-94
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,41 @@ HBS_LMS_MAX_HASH_OPTIMIZATIONS=1000 HBS_LMS_THREADS=2 cargo run --release --exam
3434
cargo run --release --example lms-demo -- verify mykey message.txt
3535
```
3636

37+
The SST extension can be used as follows:
38+
39+
```
40+
# Key generation: prepare
41+
# Generates intermediate node, generates or reads the tree identifier (init_tree_ident 1/0), and uses "mykey" as filename base.
42+
# One dedicated signing entity has to create the common L-0 tree identifier (--init_tree_ident=1) before other signing entities
43+
# can generate their subtrees.
44+
#
45+
# The following example uses two HSS levels, first with tree height = 10 / Winternitz = 8, second with 5 / 2.
46+
# First, a signing entity (here: 1 of 8) creates the tree identifier
47+
cargo run --release --example sst-demo -- prepare_keygen mykey 10/8,5/2 --ssts=1/8 --auxsize=2048 \
48+
--seed=c912a74bc8c5fc1b2a73b96e6ce1eb2317dc9aa49806b30e --init_tree_ident
49+
# The signing instance index is 3 of total 8, and this signing entity will use the tree identifier and use another secret seed.
50+
# This will use "mykey.5.prv" and "mykey.5.aux" for private key and aux data, and "mykey_treeident.bin" to write the tree identifier
51+
seq 2 8 | xargs -i{} cargo run --release --example sst-demo -- prepare_keygen mykey 10/8,5/2 --ssts={}/8 --auxsize=2048 \
52+
--seed=1eb2317dc9aa49806b30e578436d0f659b1f5c912a74bc8c
53+
54+
# Key generation: finalize
55+
# After all signing entities have created their intermediate node values, the public key can be generated.
56+
# This will use mykey.5.pub to write the public key for signing entity index 5.
57+
cargo run --release --example sst-demo -- finalize_keygen mykey 5
58+
59+
# Signing
60+
# Generates `message.txt.sig` using mykey.5.prv
61+
cargo run --release --example sst-demo -- sign mykey 5 message.txt
62+
63+
# Verification
64+
# Verifies `message.txt` with `message.txt.sig` against `mykey.5.pub`
65+
cargo run --release --example sst-demo -- verify mykey.5 message.txt
66+
67+
# Verification can as well performed with lms-demo
68+
# Verifies `message.txt` with `message.txt.sig` against `mykey.5.pub`
69+
cargo run --release --example lms-demo -- verify mykey.5 message.txt
70+
```
71+
3772
## Naming conventions wrt to the IETF RFC
3873
The naming in the RFC is done by using a single character.
3974
To allow for a better understanding of the implementation, we have decided to use more descriptive designations.

benches/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ mod tests {
135135
b.iter(|| {
136136
let mut signing_key = signing_key.clone();
137137
signing_key
138-
.try_sign_with_aux(&MESSAGE, Some(aux_slice))
138+
.try_sign_with_aux(&MESSAGE, Some(aux_slice), None)
139139
.unwrap()
140140
});
141141
}
@@ -153,7 +153,7 @@ mod tests {
153153
b.iter(|| {
154154
let mut signing_key = signing_key.clone();
155155
signing_key
156-
.try_sign_with_aux(&MESSAGE, Some(aux_slice))
156+
.try_sign_with_aux(&MESSAGE, Some(aux_slice), None)
157157
.unwrap()
158158
});
159159
}
@@ -171,7 +171,7 @@ mod tests {
171171
b.iter(|| {
172172
let mut signing_key = signing_key.clone();
173173
signing_key
174-
.try_sign_with_aux(&MESSAGE, Some(aux_slice))
174+
.try_sign_with_aux(&MESSAGE, Some(aux_slice), None)
175175
.unwrap()
176176
});
177177
}
@@ -203,7 +203,7 @@ mod tests {
203203
b.iter(|| {
204204
let mut signing_key = signing_key.clone();
205205
signing_key
206-
.try_sign_with_aux(&MESSAGE, Some(aux_slice))
206+
.try_sign_with_aux(&MESSAGE, Some(aux_slice), None)
207207
.unwrap()
208208
});
209209
}

examples/lms-demo.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl DemoError {
3939
}
4040
}
4141

42-
type Hasher = Sha256_256;
42+
type Hasher = Sha256_192;
4343

4444
struct GenKeyParameter {
4545
parameter: Vec<HssParameter<Hasher>>,
@@ -95,7 +95,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
9595
if let Some(args) = matches.subcommand_matches(VERIFY_COMMAND) {
9696
let result = verify(args);
9797
if result {
98-
println!("Successful!");
98+
println!("Verification successful!");
9999
exit(0);
100100
} else {
101101
println!("Wrong signature");
@@ -146,13 +146,15 @@ fn sign(args: &ArgMatches) -> Result<(), std::io::Error> {
146146
&private_key_data,
147147
&mut private_key_update_function,
148148
Some(aux_slice),
149+
None,
149150
)
150151
} else {
151152
hbs_lms::sign::<Hasher>(
152153
&message_data,
153154
&private_key_data,
154155
&mut private_key_update_function,
155156
None,
157+
None,
156158
)
157159
};
158160

0 commit comments

Comments
 (0)