-
Notifications
You must be signed in to change notification settings - Fork 33
Use the real crypto in formal spec tests #1586
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
ee10551
28679a9
de608db
85065c2
9ba47d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,14 +8,30 @@ import Test.Hspec ( Spec, describe, it ) | |
| import Test.HUnit ( (@?=) ) | ||
|
|
||
| import Lib | ||
| import Base (externalFunctions, sampleSignKey, deriveVkFromSk) | ||
| import Base ( | ||
| externalFunctions | ||
| , sampleSKeyDSIGN | ||
| , deriveVkeyDSIGFromSkeyDSIG | ||
| , sampleSKeyKES | ||
| , deriveVkeyKESFromSkeyKES) | ||
|
|
||
| (.->) :: a -> b -> (a, b) | ||
| (.->) = (,) | ||
|
|
||
| -- Context | ||
| coldSk :: Integer | ||
| coldSk = sampleSignKey | ||
| coldSk = sampleSKeyDSIGN | ||
|
|
||
| hotSk :: Integer | ||
| hotSk = sampleSKeyKES | ||
|
|
||
| -- Since kp = kesPeriod bhbSlot = kesPeriod 0 = 0 / SlotsPerKESPeriodᶜ = 0 / 5 = 0, | ||
| -- then period = kp -ᵏ ocC₀ = 0 - 0 = 0. | ||
| period :: Integer | ||
| period = 0 | ||
|
|
||
| skf :: Integer -> Integer | ||
| skf 0 = hotSk -- for period 0 | ||
| skf _ = succ hotSk | ||
|
|
||
| stpools :: OCertEnv | ||
| stpools = MkHSSet [] | ||
|
|
@@ -34,19 +50,19 @@ cs' = MkHSMap | |
|
|
||
| oc :: OCert | ||
| oc = MkOCert | ||
| { ocVkₕ = 123 | ||
| { ocVkₕ = deriveVkeyKESFromSkeyKES hotSk | ||
| , ocN = 234 | ||
| , ocC₀ = 0 | ||
| , ocΣ = ocΣ' | ||
| } | ||
| where | ||
| encodedOc = 0 -- since encode (ocVkₕ , ocN , ocC₀) == 0 | ||
| encodedOc = 0 -- since encode (ocVkₕ , ocN , ocC₀) = 0 | ||
| ocΣ' = externalFunctions.extSignDSIG coldSk encodedOc | ||
|
|
||
| bhb :: BHBody | ||
| bhb = MkBHBody | ||
| { bhbPrevHeader = Nothing | ||
| , bhbIssuerVk = deriveVkFromSk coldSk | ||
| , bhbIssuerVk = deriveVkeyDSIGFromSkeyDSIG coldSk | ||
| , bhbVrfVk = 567 | ||
| , bhbBlockNo = 1 | ||
| , bhbSlot = 0 | ||
|
|
@@ -61,8 +77,11 @@ bhb = MkBHBody | |
| bh :: BHeader | ||
| bh = MkBHeader | ||
| { bhBody = bhb | ||
| , bhSig = 901 | ||
| , bhSig = bhSig' | ||
| } | ||
| where | ||
| encodedBhb = 0 -- since encode bhb = 0 | ||
|
||
| bhSig' = externalFunctions.extSignKES skf period encodedBhb | ||
|
|
||
| hk :: KeyHashS | ||
| hk = succ (bhbIssuerVk bhb) -- i.e., hash (bhbIssuerVk bhb) | ||
|
|
@@ -77,12 +96,12 @@ hk = succ (bhbIssuerVk bhb) -- i.e., hash (bhbIssuerVk bhb) | |
| -- ∙ kp < ocC₀ +ᵏ MaxKESEvo <=> 0 < 0 + 30 <=> 0 < 30 <=> true | ||
| -- ∙ just 233 ≡ currentIssueNo stpools cs hk × (234 ≡ 233 ⊎ 234 ≡ suc 233)) | ||
| -- ∙ isSignedˢ bhbIssuerVk (encode (ocVkₕ , ocN , ocC₀)) ocΣ | ||
| -- <=> isSignedˢ bhbIssuerVk (encode (123 , 234 , 0)) ocΣ | ||
| -- <=> isSignedˢ bhbIssuerVk (encode (ocVkₕ , 234 , 0)) ocΣ | ||
| -- <=> isSignedˢ bhbIssuerVk 0 ocΣ | ||
| -- <=> true | ||
| -- ∙ isSignedᵏ ocVkₕ t (encode bhb) 901 | ||
| -- <=> isSignedᵏ 123 0 (encode bhb) 901 | ||
| -- <=> isSignedᵏ 123 0 0 901 | ||
| -- ∙ isSignedᵏ ocVkₕ t (encode bhb) bhSig | ||
| -- <=> isSignedᵏ ocVkₕ 0 (encode bhb) bhSig | ||
| -- <=> isSignedᵏ ocVkₕ 0 0 bhSig | ||
| -- <=> true | ||
|
|
||
| spec :: Spec | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Unsound" is a scary word. So I looked it up: https://github.com/IntersectMBO/cardano-base/blob/5c18017546dc1032e76a985c45fe7c3df2a76616/cardano-crypto-class/src/Cardano/Crypto/KES/Class.hs#L58
It's "unsound" merely because it doesn't use mlocked memory. So it's not a concern here, since this is only for conformance testing.
A little comment here with a link and one sentence summary might be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 85065c2, please check.