-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add passphrase to ledger signing api (#177)
* Add passphrase to ledger signing api This addresses #168; Instead of having the passphrase for signing hardcoded to "Ledger.Crypto PassPhrase", allow the passphrase to be provided. This way we aren't prevented from using private keys created with tools like cardano-address and cardano-cli * Add tests to verify signing and verification * Add oracle sign off-chain and on-chain prop tests * Bump materialized plans * Adds forceNewEval to release.nix Co-authored-by: John Lotoski <[email protected]>
- Loading branch information
1 parent
90c9c60
commit eba0a57
Showing
19 changed files
with
203 additions
and
44 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
1 change: 1 addition & 0 deletions
1
nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-contract.nix
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-contract.nix
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
nix/pkgs/haskell/materialized-windows/.plan.nix/plutus-contract.nix
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,43 @@ | ||
module Spec.Plutus.Contract.Oracle where | ||
|
||
import Hedgehog (Property, forAll, property) | ||
import Hedgehog qualified | ||
import Ledger.Address (PaymentPrivateKey (PaymentPrivateKey, unPaymentPrivateKey), PaymentPubKey (PaymentPubKey)) | ||
import Ledger.Crypto (generateFromSeed, toPublicKey) | ||
import Ledger.Generators qualified as Gen | ||
import Plutus.Contract.Oracle | ||
import PlutusTx.Prelude (isRight, toBuiltin) | ||
import Test.Tasty (TestTree, testGroup) | ||
import Test.Tasty.Hedgehog (testProperty) | ||
|
||
tests :: TestTree | ||
tests = | ||
testGroup | ||
"Plutus.Contract.Oracle" | ||
[ testProperty "Oracle signed payloads verify with oracle public key offchain" oracleSignOffChainProp, | ||
testProperty "Oracle signed payloads verify with on-chain constraint" oracleSignContrastraintProp | ||
] | ||
|
||
oracleSignOffChainProp :: Property | ||
oracleSignOffChainProp = property $ do | ||
seed <- forAll Gen.genSeed | ||
pass <- forAll Gen.genPassphrase | ||
msg <- forAll $ toBuiltin <$> Gen.genSizedByteString 128 | ||
|
||
let | ||
privKey = PaymentPrivateKey $ generateFromSeed seed pass | ||
pubKey = PaymentPubKey . toPublicKey . unPaymentPrivateKey $ privKey | ||
|
||
Hedgehog.assert $ isRight $ verifySignedMessageOffChain pubKey $ signMessage msg privKey pass | ||
|
||
oracleSignContrastraintProp :: Property | ||
oracleSignContrastraintProp = property $ do | ||
seed <- forAll Gen.genSeed | ||
pass <- forAll Gen.genPassphrase | ||
msg <- forAll $ toBuiltin <$> Gen.genSizedByteString 128 | ||
|
||
let | ||
privKey = PaymentPrivateKey $ generateFromSeed seed pass | ||
pubKey = PaymentPubKey . toPublicKey . unPaymentPrivateKey $ privKey | ||
|
||
Hedgehog.assert $ isRight $ verifySignedMessageConstraints pubKey $ signMessage msg privKey pass |
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
Oops, something went wrong.