-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite NIKEs and KEMs to use structure values
- Loading branch information
Showing
11 changed files
with
280 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
/- | ||
SPDX-FileCopyrightText: Copyright (C) 2024 David Stainton | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
-/ | ||
import Batteries.Classes.SatisfiesM | ||
|
||
namespace CryptWalker.kem.kem | ||
|
||
class Key (key : Type) where | ||
encode : key → ByteArray | ||
decode : ByteArray → Option key | ||
structure KEM where | ||
PublicKeyType : Type | ||
PrivateKeyType : Type | ||
|
||
class PrivateKey (privkey : Type) extends Key privkey | ||
name : String | ||
privateKeySize : Nat | ||
publicKeySize : Nat | ||
|
||
class PublicKey (pubkey : Type) extends Key pubkey | ||
generateKeyPair : IO (PublicKeyType × PrivateKeyType) | ||
encapsulate : PublicKeyType → IO (ByteArray × ByteArray) | ||
decapsulate : PrivateKeyType → ByteArray → ByteArray | ||
encodePrivateKey : PrivateKeyType → ByteArray | ||
decodePrivateKey : ByteArray → Option PrivateKeyType | ||
encodePublicKey : PublicKeyType → ByteArray | ||
decodePublicKey : ByteArray → Option PublicKeyType | ||
|
||
class KEM (scheme : Type) where | ||
PublicKeyType : Type | ||
PrivateKeyType : Type | ||
structure Key (key : Type) where | ||
encode : key → ByteArray | ||
decode : KEM → ByteArray → Option key | ||
|
||
name : String | ||
generateKeyPair : IO (PublicKeyType × PrivateKeyType) | ||
encapsulate : scheme → PublicKeyType → IO (ByteArray × ByteArray) | ||
decapsulate : scheme → PrivateKeyType → ByteArray → ByteArray | ||
privateKeySize : Nat | ||
publicKeySize : Nat | ||
encodePrivateKey : PrivateKeyType → ByteArray | ||
decodePrivateKey : ByteArray → Option PrivateKeyType | ||
encodePublicKey : PublicKeyType → ByteArray | ||
decodePublicKey : ByteArray → Option PublicKeyType | ||
structure PrivateKey (privkey : Type) extends Key privkey | ||
|
||
structure PublicKey (pubkey : Type) extends Key pubkey | ||
|
||
end CryptWalker.kem.kem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import CryptWalker.nike.x25519 | ||
import CryptWalker.nike.x448 | ||
import CryptWalker.nike.x41417 | ||
import CryptWalker.nike.nike | ||
|
||
namespace CryptWalker.nike.schemes | ||
|
||
def Schemes : List CryptWalker.nike.nike.NIKE := | ||
[ | ||
CryptWalker.nike.x25519.Scheme, | ||
CryptWalker.nike.x448.Scheme, | ||
CryptWalker.nike.x41417.Scheme, | ||
] | ||
|
||
end CryptWalker.nike.schemes |
Oops, something went wrong.