Skip to content

Commit

Permalink
Node self-sign optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jun 24, 2024
1 parent 6fdc9fd commit f8b8f08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dkgNode/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
PollingInterval = pollingInterval,
ServiceNodeUrl = serviceNodeUrl,
Address = solanaAddress,
SolanaAccount = new Account(solanaPrivateKey, solanaAddress)
PrivateKey = solanaPrivateKey
};

// These are for testing purposes only
Expand Down
13 changes: 4 additions & 9 deletions dkgNodeLibrary/Models/DkgNodeConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ public void EncodePublicKey(byte[] value)
public string? Signature { get; set; }
public void SelfSign()
{
if (SolanaAccount is null)
{
throw new Exception("Solana account is not initialized");
}

string msg = $"{Address}{PublicKey}{Name}";
byte[] msgBytes = Encoding.UTF8.GetBytes(msg);
byte[] SignatureBytes = SolanaAccount.Sign(msgBytes);
byte[] SignatureBytes = new PrivateKey(PrivateKey).Sign(msgBytes);
Signature = Convert.ToBase64String(SignatureBytes);
}

Expand All @@ -70,15 +65,15 @@ public string Name
get { return NiceName ?? Address; }
}
[JsonIgnore]
public Account SolanaAccount { get; set; }
public string PrivateKey { get; set; }
public DkgNodeConfig()
{
NiceName = null;
PublicKey = null;
Address = string.Empty;
PollingInterval = 3000;
ServiceNodeUrl = "https://localhost:8081";
SolanaAccount = new();
PrivateKey = string.Empty;
}
public DkgNodeConfig(DkgNodeConfig other)
{
Expand All @@ -87,7 +82,7 @@ public DkgNodeConfig(DkgNodeConfig other)
Address = other.Address;
PollingInterval = other.PollingInterval;
ServiceNodeUrl = other.ServiceNodeUrl;
SolanaAccount = other.SolanaAccount;
PrivateKey = other.PrivateKey;
}
}
}
Expand Down

0 comments on commit f8b8f08

Please sign in to comment.