-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add hardfork HF_Echidna #3454
Draft
Jim8y
wants to merge
40
commits into
master
Choose a base branch
from
HF_Echidna
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add hardfork HF_Echidna #3454
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
bcc5fd0
add hardofork HF_Echidna
Jim8y e63f10b
Add entries to `Designation` event (#3397)
shargon 9d16c53
[Neo Core StdLib] Add Base64url (#3453)
Jim8y f746f8d
add hardofork HF_Echidna
Jim8y 8d7f9e8
Add entries to `Designation` event (#3397)
shargon 3fc8077
[Neo Core StdLib] Add Base64url (#3453)
Jim8y 620d938
Merge branch 'HF_Echidna' of github.com:neo-project/neo into HF_Echidna
Jim8y 7e31d0c
add hardofork HF_Echidna
Jim8y 993e3fe
Add entries to `Designation` event (#3397)
shargon 37bf0cb
[Neo Core StdLib] Add Base64url (#3453)
Jim8y 7dba130
format
Jim8y 0457ccd
Merge branch 'HF_Echidna' of github.com:neo-project/neo into HF_Echidna
Jim8y d7a291e
Merge Master
cschuchardt88 6e780c0
Fixed typo
cschuchardt88 02d6ab9
Added back #3397
cschuchardt88 8fb30df
Fixed tests
cschuchardt88 f9244eb
fixed global.json
cschuchardt88 650c9e9
Merge branch 'master' into HF_Echidna
Jim8y 331541a
Merge branch 'master' into HF_Echidna
Jim8y eb96d14
Merge branch 'master' into HF_Echidna
shargon 74498e5
Merge branch 'master' into HF_Echidna
Jim8y 577c431
Merge branch 'master' into HF_Echidna
cschuchardt88 1c82ed9
Update src/Neo/Neo.csproj
cschuchardt88 b81b127
Update src/Neo/Neo.csproj
cschuchardt88 a3a6fd5
Merge branch 'master' into HF_Echidna
Jim8y c086661
Merge branch 'master' into HF_Echidna
Jim8y 0f1507f
Merge branch 'master' into HF_Echidna
Jim8y f91b680
[`Fix`]: integer overflow in `JumpTable.SubStr ` (#3496)
nan01ab 705f4bb
Fix NEO callstates (#3599)
shargon 498ed91
Merge branch 'master' into HF_Echidna
Jim8y 08c3be6
Merge branch 'master' into HF_Echidna
Jim8y 59fe8b5
fix tests error (#3636)
Jim8y a784c41
NeoToken: accept candidate registration via onNEP17Payment (#3597)
roman-khimov e2acc64
specify the argument exception information.
Jim8y 216c39e
Fix Ut (#3635)
shargon 548bd05
NeoToken: add NEP-27 to supported standards list starting from Echidn…
AnnaShaleva 8470de5
Merge branch 'master' into HF_Echidna
cschuchardt88 93fc37b
ut: fix HF_Echidna unit tests (#3646)
shargon b1a3ea3
[Core Add] Add support to Ed25519 (#3507)
Jim8y f4f1980
Merge branch 'master' into HF_Echidna
Jim8y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,99 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// Ed25519.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. | ||
|
||
using Org.BouncyCastle.Crypto.Generators; | ||
using Org.BouncyCastle.Crypto.Parameters; | ||
using Org.BouncyCastle.Crypto.Signers; | ||
using Org.BouncyCastle.Security; | ||
using System; | ||
|
||
namespace Neo.Cryptography | ||
{ | ||
public class Ed25519 | ||
{ | ||
internal const int PublicKeySize = 32; | ||
private const int PrivateKeySize = 32; | ||
internal const int SignatureSize = 64; | ||
|
||
/// <summary> | ||
/// Generates a new Ed25519 key pair. | ||
/// </summary> | ||
/// <returns>A byte array containing the private key.</returns> | ||
public static byte[] GenerateKeyPair() | ||
{ | ||
var keyPairGenerator = new Ed25519KeyPairGenerator(); | ||
keyPairGenerator.Init(new Ed25519KeyGenerationParameters(new SecureRandom())); | ||
var keyPair = keyPairGenerator.GenerateKeyPair(); | ||
return ((Ed25519PrivateKeyParameters)keyPair.Private).GetEncoded(); | ||
} | ||
|
||
/// <summary> | ||
/// Derives the public key from a given private key. | ||
/// </summary> | ||
/// <param name="privateKey">The private key as a byte array.</param> | ||
/// <returns>The corresponding public key as a byte array.</returns> | ||
/// <exception cref="ArgumentException">Thrown when the private key size is invalid.</exception> | ||
public static byte[] GetPublicKey(byte[] privateKey) | ||
{ | ||
if (privateKey.Length != PrivateKeySize) | ||
throw new ArgumentException("Invalid private key size", nameof(privateKey)); | ||
|
||
var privateKeyParams = new Ed25519PrivateKeyParameters(privateKey, 0); | ||
return privateKeyParams.GeneratePublicKey().GetEncoded(); | ||
} | ||
|
||
/// <summary> | ||
/// Signs a message using the provided private key. | ||
/// Parameters are in the same order as the sample in the Ed25519 specification | ||
/// Ed25519.sign(privkey, pubkey, msg) with pubkey omitted | ||
/// ref. https://datatracker.ietf.org/doc/html/rfc8032. | ||
/// </summary> | ||
/// <param name="privateKey">The private key used for signing.</param> | ||
/// <param name="message">The message to be signed.</param> | ||
/// <returns>The signature as a byte array.</returns> | ||
/// <exception cref="ArgumentException">Thrown when the private key size is invalid.</exception> | ||
public static byte[] Sign(byte[] privateKey, byte[] message) | ||
{ | ||
if (privateKey.Length != PrivateKeySize) | ||
throw new ArgumentException("Invalid private key size", nameof(privateKey)); | ||
|
||
var signer = new Ed25519Signer(); | ||
signer.Init(true, new Ed25519PrivateKeyParameters(privateKey, 0)); | ||
signer.BlockUpdate(message, 0, message.Length); | ||
return signer.GenerateSignature(); | ||
} | ||
|
||
/// <summary> | ||
/// Verifies an Ed25519 signature for a given message using the provided public key. | ||
/// Parameters are in the same order as the sample in the Ed25519 specification | ||
/// Ed25519.verify(public, msg, signature) | ||
/// ref. https://datatracker.ietf.org/doc/html/rfc8032. | ||
/// </summary> | ||
/// <param name="publicKey">The 32-byte public key used for verification.</param> | ||
/// <param name="message">The message that was signed.</param> | ||
/// <param name="signature">The 64-byte signature to verify.</param> | ||
/// <returns>True if the signature is valid for the given message and public key; otherwise, false.</returns> | ||
/// <exception cref="ArgumentException">Thrown when the signature or public key size is invalid.</exception> | ||
public static bool Verify(byte[] publicKey, byte[] message, byte[] signature) | ||
{ | ||
if (signature.Length != SignatureSize) | ||
throw new ArgumentException("Invalid signature size", nameof(signature)); | ||
|
||
if (publicKey.Length != PublicKeySize) | ||
throw new ArgumentException("Invalid public key size", nameof(publicKey)); | ||
|
||
var verifier = new Ed25519Signer(); | ||
verifier.Init(false, new Ed25519PublicKeyParameters(publicKey, 0)); | ||
verifier.BlockUpdate(message, 0, message.Length); | ||
return verifier.VerifySignature(signature); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ public enum Hardfork : byte | |
HF_Aspidochelone, | ||
HF_Basilisk, | ||
HF_Cockatrice, | ||
HF_Domovoi | ||
HF_Domovoi, | ||
HF_Echidna | ||
} | ||
} |
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This can be set to whatever. Better to use
AppContext.BaseDirectory