Skip to content

Commit

Permalink
add types
Browse files Browse the repository at this point in the history
  • Loading branch information
colinxu2020 committed Jul 16, 2024
1 parent 6c88406 commit 184fd23
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion slhdsa/lowlevel/slhdsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def keygen(par: Parameter) -> tuple[tuple[bytes, bytes, bytes, bytes], tuple[byt

def validate_secretkey(secret_key: tuple[bytes, bytes, bytes, bytes], par: Parameter) -> bool:
sk_seed, sk_prf, pk_seed, pk_root = secret_key
# len(sk_prf) # magic patch for mypyc, otherwise mypyc will crash
len(sk_prf) # magic patch for mypyc, otherwise mypyc will crash
address = Address(par.d - 1, 0, 0)
pk_root_new = XMSS(par).node(sk_seed, 0, par.h_m, pk_seed, address)
return pk_root == pk_root_new
Expand Down
4 changes: 2 additions & 2 deletions slhdsa/slhdsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def from_digest(cls, digest: bytes, par: Parameter) -> "PublicKey":
raise exc.SLHDSAKeyException('Wrong digest length')
return cls((digest[:par.n], digest[par.n:]), par)

def __str__(self):
def __str__(self) -> str:
return f'<SLHDSA Public Key: {self.digest().hex()}>'


Expand Down Expand Up @@ -55,7 +55,7 @@ def from_digest(cls, digest: bytes, par: Parameter) -> "SecretKey":
raise exc.SLHDSAKeyException("Wrong digest length")
return cls((digest[:par.n], digest[par.n:par.n*2], digest[par.n*2:par.n*3], digest[par.n*3:]), par)

def __str__(self):
def __str__(self) -> str:
return f'<SLHDSA Secret Key: {self.digest().hex()}>'


Expand Down

0 comments on commit 184fd23

Please sign in to comment.