/// <summary> /// Signs the request with owner's Private key. /// </summary> /// <param name="request">The request.</param> /// <param name="privateKey">The private key.</param> public void SelfSign(SignableRequest request, PrivateKey privateKey) { var fingerprint = this.crypto.CalculateFingerprint(request.Snapshot); var signature = this.crypto.Sign(fingerprint.GetValue(), privateKey); request.AppendSignature(fingerprint.ToHEX(), signature); }
public void AuthoritySign(SignableRequest request, string appId, PrivateKey appKey) { var fingerprint = this.crypto.CalculateFingerprint(request.Snapshot); var signature = this.crypto.Sign(fingerprint.GetValue(), appKey); request.AppendSignature(appId, signature); }
/// <summary> /// Signs the request as authority. /// </summary> public void SignRequest(SignableRequest request, string appId) { if (string.IsNullOrWhiteSpace(appId)) { throw new ArgumentException(Localization.ExceptionArgumentIsNullOrWhitespace, nameof(appId)); } var signer = VirgilConfig.GetService <RequestSigner>(); signer.AuthoritySign(request, appId, this.KeyPair.PrivateKey); }
public void Export_WithoutParameters_ShouldBeEquivalentToImportedRequest() { var crypto = new VirgilCrypto(); var aliceKeys = crypto.GenerateKeys(); var exportedPublicKey = crypto.ExportPublicKey(aliceKeys.PublicKey); const string identity = "alice"; const string identityType = "member"; var request = new CreateCardRequest ( identity, identityType, exportedPublicKey, new Dictionary <string, string> { ["key1"] = "value1", ["key2"] = "value2" }, new DeviceInfo { Device = "Device", DeviceName = "DeviceName" } ); var requestSigner = new RequestSigner(crypto); requestSigner.SelfSign(request, aliceKeys.PrivateKey); var exportedRequest = request.Export(); var importedRequest = SignableRequest.Import <CreateCardRequest>(exportedRequest); request.ShouldBeEquivalentTo(importedRequest); }