Skip to content

LMS: add more examples #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ pq/stateful_hash_sig/xmss_example
pq/stateful_hash_sig/xmss_example.key
pq/stateful_hash_sig/lms_example
pq/stateful_hash_sig/lms_example.key
pq/stateful_hash_sig/lms-kg
pq/stateful_hash_sig/lms-sign
pq/stateful_hash_sig/lms-verify
pq/stateful_hash_sig/lms_key.bin
pq/stateful_hash_sig/lms_pubkey.bin
pq/stateful_hash_sig/*.sig

# PQ ML-DSA
pq/ml_dsa/ml_dsa_test
Expand Down
17 changes: 17 additions & 0 deletions pq/stateful_hash_sig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ lms_example: lms_example.c
# If building with ext_lms (--enable-lms --with-liblms=<path>):
# $(CC) -o $@ $< $(CFLAGS) -I$(HSS_INC) $(LIBS) $(WOLF_STATIC_LIB) $(HSS_LIB)

lms-kg: lms-kg.c
# If building with wc_lms (--enable-lms):
$(CC) -o $@ $< $(CFLAGS) -DWOLFSSL_WC_LMS $(LIBS) $(WOLF_DYN_LIB)
# If building with ext_lms (--enable-lms --with-liblms=<path>):
# $(CC) -o $@ $< $(CFLAGS) -I$(HSS_INC) $(LIBS) $(WOLF_STATIC_LIB) $(HSS_LIB)

lms-sign: lms-sign.c
# If building with wc_lms (--enable-lms):
$(CC) -o $@ $< $(CFLAGS) -DWOLFSSL_WC_LMS $(LIBS) $(WOLF_DYN_LIB)
# If building with ext_lms (--enable-lms --with-liblms=<path>):
# $(CC) -o $@ $< $(CFLAGS) -I$(HSS_INC) $(LIBS) $(WOLF_STATIC_LIB) $(HSS_LIB)

lms-verify: lms-verify.c
# If building with wc_lms (--enable-lms):
$(CC) -o $@ $< $(CFLAGS) -DWOLFSSL_WC_LMS $(LIBS) $(WOLF_DYN_LIB)
# If building with ext_lms (--enable-lms --with-liblms=<path>):
# $(CC) -o $@ $< $(CFLAGS) -I$(HSS_INC) $(LIBS) $(WOLF_STATIC_LIB) $(HSS_LIB)
xmss_example: xmss_example.c
# If building with wc_xmss (--enable-xmss):
$(CC) -o $@ $< $(CFLAGS) -DWOLFSSL_WC_XMSS $(LIBS) $(WOLF_DYN_LIB)
Expand Down
77 changes: 77 additions & 0 deletions pq/stateful_hash_sig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,83 @@ examples:
description:
...
```

## Generate an LMS private/public key pair

This example generates an LMS public/private key pair and stores them to file.

```sh
$./lms-kg
Levels: 1, Height: 10, Winternitz: 4
Writing to file: lms_key.bin
Writing to file: lms_pubkey.bin

$./lms-kg --params 54
Using parameters: LMS/HSS_SHA256/192_L1_H20_W4
Writing to file: lms_key.bin
Writing to file: lms_pubkey.bin
```

## Sign files with LMS private key

This example uses an LMS private key to sign multiple files.

```sh
$./lms-sign Makefile README.md
Levels: 1, Height: 10, Winternitz: 4
Reading from file: lms_key.bin
Read 56 bytes
Ready to sign
Reading from file: Makefile
Read 2455 bytes
Writing to file: lms_key.bin
Writing to file: Makefile.sig
Reading from file: README.md
Read 7756 bytes
Writing to file: lms_key.bin
Writing to file: README.md.sig

$./lms-sign --params 54 Makefile README.md
Using parameters: LMS/HSS_SHA256/192_L1_H20_W4
Reading from file: lms_key.bin
Read 56 bytes
Ready to sign
Reading from file: Makefile
Read 2455 bytes
Writing to file: lms_key.bin
Writing to file: Makefile.sig
Reading from file: README.md
Read 7756 bytes
Writing to file: lms_key.bin
Writing to file: README.md.sig
```

## Verify file with LMS public key

This example uses an LMS public key to verify a file against its signature.

```sh
$./lms-verify README.md
Levels: 1, Height: 10, Winternitz: 4
Reading from file: lms_pubkey.bin
Read 52 bytes
Reading from file: README.md
Read 7756 bytes
Reading from file: README.md.sig
Read 1744 bytes
Verification succeeded

$./lms-verify --params 54 README.md
Using parameters: LMS/HSS_SHA256/192_L1_H20_W4
Reading from file: lms_pubkey.bin
Read 52 bytes
Reading from file: README.md
Read 7756 bytes
Reading from file: README.md.sig
Read 1744 bytes
Verification succeeded
```

## Signing and Verifying a Message with XMSS/XMSS^MT

To see the help and usage, run the program without options:
Expand Down
Loading