SHA256
Миграция PDA на client.key
This commit is contained in:
@@ -43,7 +43,7 @@ type SessionRecord = {
|
||||
};
|
||||
|
||||
type MutableFields = {
|
||||
deviceKey: PublicKey;
|
||||
clientKey: PublicKey;
|
||||
blockchainPublicKey: PublicKey;
|
||||
blockchainName: string;
|
||||
usedBytes: bigint;
|
||||
@@ -69,7 +69,7 @@ type UnsignedRecord = {
|
||||
prevRecordHash: Buffer;
|
||||
login: string;
|
||||
rootKey: PublicKey;
|
||||
deviceKey: PublicKey;
|
||||
clientKey: PublicKey;
|
||||
blockchain: {
|
||||
blockchainType: number;
|
||||
blockchainName: string;
|
||||
@@ -126,7 +126,7 @@ function serializeUnsignedRecord(r: UnsignedRecord): Buffer {
|
||||
out.push(Buffer.from([BLOCK_TYPE_ROOT_KEY, BLOCK_VERSION_0]));
|
||||
out.push(r.rootKey.toBuffer());
|
||||
out.push(Buffer.from([BLOCK_TYPE_DEVICE_KEY, BLOCK_VERSION_0]));
|
||||
out.push(r.deviceKey.toBuffer());
|
||||
out.push(r.clientKey.toBuffer());
|
||||
out.push(Buffer.from([BLOCK_TYPE_BLOCKCHAIN_REGISTRY, BLOCK_VERSION_0, 1]));
|
||||
out.push(Buffer.from([r.blockchain.blockchainType]));
|
||||
out.push(strBytes(r.blockchain.blockchainName));
|
||||
@@ -222,11 +222,11 @@ describe("shine_users e2e", () => {
|
||||
|
||||
const root = anchor.web3.Keypair.generate();
|
||||
const blockchain = anchor.web3.Keypair.generate();
|
||||
const deviceKey = anchor.web3.Keypair.generate().publicKey;
|
||||
const clientKey = anchor.web3.Keypair.generate().publicKey;
|
||||
const blockchainName = `${login}-001`;
|
||||
|
||||
const createFields: MutableFields = {
|
||||
deviceKey,
|
||||
clientKey,
|
||||
blockchainPublicKey: blockchain.publicKey,
|
||||
blockchainName,
|
||||
usedBytes: 0n,
|
||||
@@ -256,7 +256,7 @@ describe("shine_users e2e", () => {
|
||||
prevRecordHash: ZERO_HASH,
|
||||
login,
|
||||
rootKey: root.publicKey,
|
||||
deviceKey,
|
||||
clientKey,
|
||||
blockchain: {
|
||||
blockchainType: BLOCKCHAIN_TYPE_MAIN_USER,
|
||||
blockchainName,
|
||||
@@ -301,7 +301,7 @@ describe("shine_users e2e", () => {
|
||||
createdAtMs: new anchor.BN(createdAtMs.toString()),
|
||||
additionalLimit: new anchor.BN(additionalLimitCreate.toString()),
|
||||
fields: {
|
||||
deviceKey: createFields.deviceKey,
|
||||
clientKey: createFields.clientKey,
|
||||
blockchainPublicKey: createFields.blockchainPublicKey,
|
||||
blockchainName: createFields.blockchainName,
|
||||
usedBytes: new anchor.BN(createFields.usedBytes.toString()),
|
||||
@@ -343,9 +343,9 @@ describe("shine_users e2e", () => {
|
||||
|
||||
const additionalLimitUpdate = 30_000n;
|
||||
expect(additionalLimitUpdate % LIMIT_STEP).eq(0n);
|
||||
const updatedDeviceKey = anchor.web3.Keypair.generate().publicKey;
|
||||
const updatedClientKey = anchor.web3.Keypair.generate().publicKey;
|
||||
const updateFields: MutableFields = {
|
||||
deviceKey: updatedDeviceKey,
|
||||
clientKey: updatedClientKey,
|
||||
blockchainPublicKey: blockchain.publicKey,
|
||||
blockchainName,
|
||||
usedBytes: 512n,
|
||||
@@ -371,7 +371,7 @@ describe("shine_users e2e", () => {
|
||||
prevRecordHash: sha256(createUnsigned),
|
||||
login,
|
||||
rootKey: root.publicKey,
|
||||
deviceKey: updatedDeviceKey,
|
||||
clientKey: updatedClientKey,
|
||||
blockchain: {
|
||||
blockchainType: BLOCKCHAIN_TYPE_MAIN_USER,
|
||||
blockchainName,
|
||||
@@ -419,7 +419,7 @@ describe("shine_users e2e", () => {
|
||||
prevHash: sha256(createUnsigned),
|
||||
additionalLimit: new anchor.BN(additionalLimitUpdate.toString()),
|
||||
fields: {
|
||||
deviceKey: updateFields.deviceKey,
|
||||
clientKey: updateFields.clientKey,
|
||||
blockchainPublicKey: updateFields.blockchainPublicKey,
|
||||
blockchainName: updateFields.blockchainName,
|
||||
usedBytes: new anchor.BN(updateFields.usedBytes.toString()),
|
||||
|
||||
Reference in New Issue
Block a user