Skip to content

Commit

Permalink
fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
larskuhtz committed Jul 15, 2024
1 parent 3837c4c commit 8df1cff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ethereum.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ library
, aeson >=2.2
, base16-bytestring >=0.1
, binary >=0.8
, bytestring >=0.10.12
, bytestring >=0.11.3
, exceptions >=0.10
, hashable >=1.2
, hashes >=0.3
Expand Down
3 changes: 1 addition & 2 deletions src/Ethereum/RLP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,11 @@ putRlpB x
--
putRlpBShort :: BS.ShortByteString -> Put
putRlpBShort x
| lx == 1 && h x < 127 = put8 (h x)
| lx == 1 && BS.head x < 127 = put8 (BS.head x)
| lx < 56 = put8 (int $ 128 + lx) <> putShort x
| lx <= maxBound @Word64 = put8 (int $ 183 + byteCount belx) <> belx <> putShort x
| otherwise = error $ "Byte arrays containing 2^64 or more bytes cannot be encoded: " <> show lx
where
h = head . BS.unpack
belx = putBe lx

lx :: Word64
Expand Down
25 changes: 13 additions & 12 deletions test-secp256k1/Test/Crypto/Secp256k1/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import Crypto.Secp256k1
-- Examples
-- -------------------------------------------------------------------------- --

sk1, h1, r1, s1 :: Fn
sk1 = fn 0xebb2c082fd7727890a28ac82f6bdf97bad8de9f5d7c9028692de1a255cad3e0f
_sk1, h1, r1, s1 :: Fn
_sk1 = fn 0xebb2c082fd7727890a28ac82f6bdf97bad8de9f5d7c9028692de1a255cad3e0f
h1 = fn 0x4b688df40bcedbe641ddb16ff0a1842d9c67ea1c3bf63f3e0471baa664531d1a
r1 = fn 0x241097efbf8b63bf145c8961dbdf10c310efbb3b2676bbc0f8b08505c9e2f795
s1 = fn 0x021006b7838609339e8b415a7f9acb1b661828131aef1ecbc7955dfb01f3ca0e
Expand Down Expand Up @@ -76,12 +76,12 @@ properties_example1 = testGroup "example1"
, testProperty "test_2_recover" test_2_recover
]

sk2, k2, h2, r2, s2 :: Fn
sk2 = fn 0xebb2c082fd7727890a28ac82f6bdf97bad8de9f5d7c9028692de1a255cad3e0f
k2 = fn 0x49a0d7b786ec9cde0d0721d72804befd06571c974b191efb42ecf322ba9ddd9a
h2 = fn 0x4b688df40bcedbe641ddb16ff0a1842d9c67ea1c3bf63f3e0471baa664531d1a
r2 = fn 0x241097efbf8b63bf145c8961dbdf10c310efbb3b2676bbc0f8b08505c9e2f795
s2 = fn 0x021006b7838609339e8b415a7f9acb1b661828131aef1ecbc7955dfb01f3ca0e
_sk2, _k2, _h2, _r2, _s2 :: Fn
_sk2 = fn 0xebb2c082fd7727890a28ac82f6bdf97bad8de9f5d7c9028692de1a255cad3e0f
_k2 = fn 0x49a0d7b786ec9cde0d0721d72804befd06571c974b191efb42ecf322ba9ddd9a
_h2 = fn 0x4b688df40bcedbe641ddb16ff0a1842d9c67ea1c3bf63f3e0471baa664531d1a
_r2 = fn 0x241097efbf8b63bf145c8961dbdf10c310efbb3b2676bbc0f8b08505c9e2f795
_s2 = fn 0x021006b7838609339e8b415a7f9acb1b661828131aef1ecbc7955dfb01f3ca0e

-- -------------------------------------------------------------------------- --
-- Tests Tools
Expand All @@ -95,7 +95,9 @@ genSecretKey = bytesToFn <$> getEntropy 32
genKey :: IO (Fn, Point)
genKey = do
sk <- genSecretKey
return (sk, sk .*. gC)
case getPublicKey sk of
O -> error "invalid public key"
pk -> return (sk, pk)

-- |
--
Expand Down Expand Up @@ -129,9 +131,8 @@ sign
-> IO (Fn, Fn, Bool, Bool)
-- ^ (r, s, isOddY, isSecondKey)
sign sk e = do
k <- genSecretKey
let (Point xr yr) = getPublicKey k
r = zConv xr
(k, Point xr yr) <- genKey
let r = zConv xr
if r == fn 0
then sign sk e -- start over
else do
Expand Down

0 comments on commit 8df1cff

Please sign in to comment.