Permalink
Browse files

add signatureByteString function

  • Loading branch information...
vmchale committed Feb 9, 2019
1 parent 6780ce6 commit 0a9fd79a5c2b6b38e35f80be136fef559e63e6c1
Showing with 33 additions and 1 deletion.
  1. +3 −1 bench-primitives/bench-primitives.cabal
  2. +25 −0 bench-primitives/bench/Bench.hs
  3. +5 −0 cabal.project
@@ -35,7 +35,9 @@ benchmark bench-primitives-bench
deepseq -any,
language-plutus-core -any,
bytestring -any,
integer-logarithms -any
integer-logarithms -any,
cardano-crypto,
cryptonite

if flag(development)
ghc-options: -Werror
@@ -1,9 +1,12 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import Control.DeepSeq (NFData)
import Criterion.Main
import Crypto.ECC.Ed25519Donna
import Crypto.Error
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as BSL
import qualified Data.ByteString.Lazy.Char8 as ASCII
@@ -32,6 +35,28 @@ bytestrings = [ ASCII.replicate 1 'a'
, ASCII.replicate 1000 'a'
]

-- signature size: 64 bytes
-- b = 256 bits
-- Based on: Ed25519

emptySig :: BSL.ByteString
emptySig = BSL.replicate 512 0

emptyPubKey :: BSL.ByteString
emptyPubKey = BSL.replicate 256 0

packSig :: BSL.ByteString -> CryptoFailable Signature
packSig = signature . BSL.toStrict

packPubKey :: BSL.ByteString -> CryptoFailable PublicKey
packPubKey = publicKey . BSL.toStrict

signatureByteString :: BSL.ByteString -- ^ Public key
-> BSL.ByteString -- ^ Message
-> BSL.ByteString -- ^ Signature
-> CryptoFailable Bool
signatureByteString pubKey msg sig = verify <$> packPubKey pubKey <*> pure (BSL.toStrict msg) <*> packSig sig

main :: IO ()
main =
defaultMain [ bgroup "Integer Addition" $
@@ -41,3 +41,8 @@ source-repository-package
type: git
location: https://github.com/shmish111/servant-purescript.git
tag: 315ccf5d720937c091c8cf3aca8adc8110766a23

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-crypto.git
tag: f5cecb6e424cc84f85b6a3e1f803517bb7b4cfb1

0 comments on commit 0a9fd79

Please sign in to comment.