Prevention of Playing Signature Solane ED25519 with Original Programs
When using Solan’s original ED25519 program to check the signature of the message, measures should be taken to prevent repetition attacks. One of the usual technologies is to add a presentation that includes the signature of the sender, the message and the public key. In this article, we investigate that this security feature is achieved in the adapted program.
Why prevent signature playback?
Signature repetition attacks occur when the attacker records and re -uses a previously certified signature. This can be devastating for systems based in salt pans, as it allows attackers to monitor legal users and carry out harmful events without consequences.
ED25519 SORANE CONTRACTS
In order to prevent the signature of the signature, we use the “Soran -Program” library that offers implementation of original programs in Blockchain Soran. We are focused on the creation of pre -Drivity that includes the signature, messages and the public key of the sender.
Here’s an example of how to create pre -law with pre -type Typescript:
`Tiprapt
To bring {program} ‘@soan-project/spl-project;
To bring {soclan process} ‘../src’;
Const programd = ‘your_ process’; // Replace with the program ID
SignorerplayPreinstruction category expands the program {{
Async Getprogramdata (Programmide: String): Promise
Const signature = ‘your_signature_here’; // Replace yourself with a real signature
Const Message = ‘Your_message_hhere’; // Replace the actual message
Const Publicky = ‘Your_public_KEY_HERE’; // Replace yourself with the actual public key
Return json.stringify ({{{
signature,
message,
Publicky,
});
Iche
Async Execute (programming: string, Data: string): promise
if (Data.startswith (‘Pre_instruction’))
Const Preinstruction = Json.parers (Data.substring (9));
Console.log (received before -the need for signature $ {preinstruction.signation}, message $ {prenstruction.message} and public key $ {preinstruction.publcykey
);
Iche
Iche
Iche
// Start the program
Const Program = New Solan Program (Programmide, signatureplaypreinstruction);
`
In this example, we define the Class signatinstruction
signature that expands the program of the” Program “. The “Getprogramdata” method returns a string containing the signature, message and public key of the sender.
The “Run” method checks that the “Pre_instruction” data starts. If this happens, the data will be structured as JSON and record the contents in the console.
ED25519 pre-installation for the use of pre-instruction
In order to use a presentation in the program ED25519, you must edit the “Nativescript” feature from the information received information to remove signatures, messages and public key. Here’s an example of how this is done:
`Tiprapt
Bring {program} ‘@soana-program/spl-project;
Import {ed25519NATIVITSCRIPT} ‘../src’;
Const programd = ‘your_ process’; // Replace with the program ID
SignorerplayPreinstruction category expands the program {{
Async Getprogramdata (Programmide: String): Promise
Const signature = ‘your_signature_here’; // Replace yourself with a real signature
Const Message = ‘Your_message_hhere’; // Replace the actual message
Const Publickey = ‘Your_public_KEY_HERE’; // Replace yourself with the actual public key
Return json.stringify ({{{
signature,
message,
Publicky,
});
Iche
Async Execute (programming: string, Data: string): promise
if (Data.startswith (‘Pre_instruction’))
Const Pre -Preinstructiondata = Data.Substring (9);
Const [signature, message, publiciscey] = preinstructiondata.pit (‘,’);
console.