Skip to content
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 ECRecoverProvider #5

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Stratis.SmartContracts/IEcRecoverProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Stratis.SmartContracts
{
public interface IEcRecoverProvider
{
Address GetSigner(byte[] message, byte[] signature);
}
}
1 change: 1 addition & 0 deletions Stratis.SmartContracts/ISmartContractState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface ISmartContractState
IInternalTransactionExecutor InternalTransactionExecutor { get; }
IInternalHashHelper InternalHashHelper { get; }
ISerializer Serializer { get; }
IEcRecoverProvider EcRecoverProvider { get; }
Func<ulong> GetBalance { get; }
}
}
11 changes: 11 additions & 0 deletions Stratis.SmartContracts/SmartContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ protected byte[] Keccak256(byte[] toHash)
return this.state.InternalHashHelper.Keccak256(toHash);
}

/// <summary>
/// Recovers the address that signed a message from its message and signature.
/// </summary>
/// <param name="message">The message that was signed.</param>
/// <param name="signature">The signature.</param>
/// <returns>The address of the signer.</returns>
protected Address EcRecover(byte[] message, byte[] signature)
{
return this.state.EcRecoverProvider.GetSigner(message, signature);
}

/// <summary>
/// Halts contract execution by throwing an exception if the input condition is not met.
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions Stratis.SmartContracts/Stratis.SmartContracts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
<Authors>Stratis Group Ltd.</Authors>
<Company>Stratis Group Ltd.</Company>
<Product>Stratis Smart Contracts</Product>
<Version>1.2.1</Version>
<Version>1.2.2-dev</Version>
<PackageId>Stratis.SmartContracts</PackageId>
<CodeAnalysisRuleSet>..\None.ruleset</CodeAnalysisRuleSet>
<AssemblyVersion>1.2.1.0</AssemblyVersion>
<AssemblyVersion>1.2.2.0</AssemblyVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

</Project>