-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Native: extend CryptoLib's verifyWithECDsa with hasher parameter
A port of nspcc-dev/neo-go@1e2b438. This commit contains minor protocol extension needed for custom Koblitz-based verification scripts (an alternative to #3205). Replace native CryptoLib's verifyWithECDsa `curve` parameter by `curveHash` parameter which is a enum over supported pairs of named curves and hash functions. NamedCurve enum mark as deprecated and replaced by NamedCurveHash with compatible behaviour. Even though this change is a compatible extension of the protocol, it changes the genesis state due to parameter renaming (CryptoLib's manifest is changed). But we're going to resync chain in 3.7 release anyway, so it's not a big deal. Also, we need to check mainnet and testnet compatibility in case if anyone has ever called verifyWithECDsa with 24 or 25 `curve` value. Signed-off-by: Anna Shaleva <[email protected]>
- Loading branch information
1 parent
f6c26cb
commit b77b5ed
Showing
7 changed files
with
170 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// Hasher.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
namespace Neo.Cryptography | ||
{ | ||
/// <summary> | ||
/// Represents hash function identifiers supported by ECDSA message signature and verification. | ||
/// </summary> | ||
public enum Hasher : byte | ||
{ | ||
/// <summary> | ||
/// The SHA256 hash algorithm. | ||
/// </summary> | ||
SHA256 = 0x00, | ||
|
||
/// <summary> | ||
/// The Keccak256 hash algorithm. | ||
/// </summary> | ||
Keccak256 = 0x01, | ||
} | ||
} |
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 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// NamedCurveHash.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
namespace Neo.SmartContract.Native | ||
{ | ||
/// <summary> | ||
/// Represents a pair of the named curve used in ECDSA and a hash algorithm used to hash message. | ||
/// This is a compatible extension of an obsolete <see cref="NamedCurve"/> enum. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://tools.ietf.org/html/rfc4492#section-5.1.1 | ||
/// </remarks> | ||
public enum NamedCurveHash : byte | ||
{ | ||
/// <summary> | ||
/// The secp256k1 curve and SHA256 hash algorithm. | ||
/// </summary> | ||
secp256k1SHA256 = 22, | ||
|
||
/// <summary> | ||
/// The secp256r1 curve, which known as prime256v1 or nistP-256, and SHA256 hash algorithm. | ||
/// </summary> | ||
secp256r1SHA256 = 23, | ||
|
||
/// <summary> | ||
/// The secp256k1 curve and Keccak256 hash algorithm. | ||
/// </summary> | ||
secp256k1Keccak256 = 24, | ||
|
||
/// <summary> | ||
/// The secp256r1 curve, which known as prime256v1 or nistP-256, and Keccak256 hash algorithm. | ||
/// </summary> | ||
secp256r1Keccak256 = 25 | ||
} | ||
} |
Oops, something went wrong.