-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from make-software/release/v1.4.3
Release/v1.4.3
- Loading branch information
Showing
19 changed files
with
261 additions
and
66 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
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,6 @@ | ||
{ | ||
"key": "balance-cac81394a4906c62a999c4b3c24d886c452b0a9ed39419e6e8f861d72ee59303", | ||
"transform": { | ||
"AddUInt512": "100000000" | ||
} | ||
} |
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,14 @@ | ||
{ | ||
"key": "deploy-e379d531188e90892ca07dba8469def6f9a45e627717b2a3ae4a8ec440c9f001", | ||
"transform": { | ||
"WriteDeployInfo": { | ||
"deploy_hash": "e379d531188e90892ca07dba8469def6f9a45e627717b2a3ae4a8ec440c9f001", | ||
"transfers": [ | ||
"transfer-78c4663dd4b83fa35d031e8173dccb53431520adf559a3853892530946fcb777" | ||
], | ||
"from": "account-hash-e15156d73d79f92b13aa147552a01ef2a3d677134f13961b51033ffd9fba481c", | ||
"source": "uref-012e4506440c6bf5427d3d76ad20a1bdefc6bf5d79cee3d28bfaae36603f1133-007", | ||
"gas": "100000000" | ||
} | ||
} | ||
} |
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,42 @@ | ||
package types | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/make-software/casper-go-sdk/types" | ||
) | ||
|
||
func Test_Transform_AddUInt512(t *testing.T) { | ||
fixture, err := os.ReadFile("../data/transform/AddUInt512.json") | ||
require.NoError(t, err) | ||
var transformKey types.TransformKey | ||
|
||
err = json.Unmarshal(fixture, &transformKey) | ||
require.NoError(t, err) | ||
|
||
val, err := transformKey.Transform.ParseAsUInt512() | ||
require.NoError(t, err) | ||
|
||
assert.True(t, transformKey.Transform.IsAddUint512()) | ||
assert.EqualValues(t, 100000000, val.Value().Int64()) | ||
} | ||
|
||
func Test_Transform_WriteDeployInfo(t *testing.T) { | ||
fixute, err := os.ReadFile("../data/transform/WriteDeployInfo.json") | ||
require.NoError(t, err) | ||
var transformKey types.TransformKey | ||
|
||
err = json.Unmarshal(fixute, &transformKey) | ||
require.NoError(t, err) | ||
|
||
val, err := transformKey.Transform.ParseAsWriteDeployInfo() | ||
require.NoError(t, err) | ||
|
||
assert.True(t, transformKey.Transform.IsWriteDeployInfo()) | ||
assert.EqualValues(t, 1, len(val.Transfers)) | ||
} |
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 @@ | ||
package ed25519 | ||
|
||
import ( | ||
"crypto/ed25519" | ||
"encoding/pem" | ||
) | ||
|
||
const PemFramePrivateKeyPrefixSize = 16 | ||
|
||
func PrivateKeyToPem(priv ed25519.PrivateKey) ([]byte, error) { | ||
// Extract the seed (first 32 bytes of the private key) | ||
seed := priv[:32] | ||
|
||
// Create the prefix for the seed | ||
prefix := make([]byte, PemFramePrivateKeyPrefixSize) | ||
|
||
// Combine the prefix and the seed to match the original format | ||
fullKey := append(prefix, seed...) | ||
|
||
return pem.EncodeToMemory( | ||
&pem.Block{ | ||
Type: "PRIVATE KEY", | ||
Bytes: fullKey, | ||
}, | ||
), nil | ||
} | ||
|
||
func NewPrivateKeyFromPEM(content []byte) (PrivateKey, error) { | ||
block, _ := pem.Decode(content) | ||
// Trim PEM prefix | ||
data := block.Bytes[PemFramePrivateKeyPrefixSize:] | ||
// Use only last 32 bytes of private Key | ||
privateKeySize := len(data) | ||
if privateKeySize > 32 { | ||
data = data[privateKeySize%32:] | ||
} | ||
|
||
privateEdDSA := ed25519.NewKeyFromSeed(data) | ||
|
||
return PrivateKey{ | ||
key: privateEdDSA, | ||
}, nil | ||
} |
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.