private CardModel BuildCardModel ( string identity, string identityType, Dictionary <string, string> customFields, CardScope scope, VirgilKey ownerKey ) { var cardSnapshotModel = new PublishCardSnapshotModel { Identity = identity, IdentityType = identityType, Info = new CardInfoModel { DeviceName = this.context.DeviceManager.GetDeviceName(), Device = this.context.DeviceManager.GetSystemName() }, PublicKeyData = ownerKey.ExportPublicKey().GetBytes(), Scope = scope, Data = customFields }; var snapshot = new Snapshotter().Capture(cardSnapshotModel); var snapshotFingerprint = this.context.Crypto.CalculateFingerprint(snapshot); var cardId = snapshotFingerprint.ToHEX(); var selfSignature = ownerKey.Sign(VirgilBuffer.From(snapshotFingerprint.GetValue())); var signatures = new Dictionary <string, byte[]> { [cardId] = selfSignature.GetBytes() }; var cardModel = new CardModel(cardSnapshotModel) { Id = cardId, Snapshot = snapshot, Meta = new CardMetaModel { Signatures = signatures } }; return(cardModel); }
/// <summary> /// To check if current Virgil Card was generated for <paramref name="virgilKey"/>. /// </summary> /// <param name="virgilKey">An instance of <see cref="VirgilKey"/>.</param> public bool IsPairFor(VirgilKey virgilKey) { return(this.PublicKey.Get().Value.SequenceEqual(virgilKey.ExportPublicKey().GetBytes())); }