Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Bryan Montz <[email protected]>
  • Loading branch information
tyiu and bryanmontz authored May 28, 2024
1 parent a7dcf55 commit b38fe8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Sources/NostrSDK/Events/GiftWrap/GiftWrapEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public final class GiftWrapEvent: NostrEvent, NIP44v2Encrypting {
}

public init(content: String, tags: [Tag] = [], createdAt: Int64 = Int64(Date.now.timeIntervalSince1970 - TimeInterval.random(in: 0...172800)), signedBy keypair: Keypair) throws {
try super.init(kind: .seal, content: content, tags: tags, createdAt: createdAt, signedBy: keypair)
try super.init(kind: .giftWrap, content: content, tags: tags, createdAt: createdAt, signedBy: keypair)
}

/// Unwraps the content of the gift wrap event and decrypts it into a ``SealEvent``.
/// - Parameters:
/// - privateKey: The ``PrivateKey`` to decrypt the content.
/// - Returns: The ``SealEvent``.
public func unwrap(privateKey: PrivateKey) throws -> SealEvent {
public func unwrappedSeal(using privateKey: PrivateKey) throws -> SealEvent {
guard let wrapperPublicKey = PublicKey(hex: pubkey) else {
throw GiftWrapError.pubkeyInvalid
}
Expand Down Expand Up @@ -93,12 +93,12 @@ public extension EventCreating {
return try giftWrap(withSeal: seal, toRecipient: recipient, tags: tags, createdAt: createdAt, signedBy: keypair)
}

/// Creates a ``GiftWrapEvent`` that takes a signed``SealEvent``, and then wraps that seal encrypted in the content of the gift wrap.
/// Creates a ``GiftWrapEvent`` that takes a signed ``SealEvent``, and then wraps that seal encrypted in the content of the gift wrap.
///
/// - Parameters:
/// - withSeal: a signed ``SealEvent``.
/// - toRecipient: the ``PublicKey`` of the receiver of the event.
/// - tags: the list of tags
/// - tags: the list of tags.
/// - createdAt: the creation timestamp of the seal. Note that this timestamp SHOULD be tweaked to thwart time-analysis attacks. Note that some relays don't serve events dated in the future, so all timestamps SHOULD be in the past. By default, if `createdAt` is not provided, a random timestamp within 2 days in the past will be chosen.
/// - keypair: The real ``Keypair`` to sign the seal with. Note that a different random one-time use key is used to sign the gift wrap.
func giftWrap(
Expand Down
2 changes: 1 addition & 1 deletion Sources/NostrSDK/Events/GiftWrap/SealEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class SealEvent: NostrEvent, NIP44v2Encrypting {
/// - Parameters:
/// - privateKey: The ``PrivateKey`` to decrypt the rumor.
/// - Returns: The decrypted ``NostrEvent`` rumor, where its `signature` is `nil`.
public func unseal(privateKey: PrivateKey) throws -> NostrEvent {
public func unsealedRumor(using privateKey: PrivateKey) throws -> NostrEvent {
guard let authorPublicKey = PublicKey(hex: pubkey) else {
throw SealEventError.pubkeyInvalid
}
Expand Down

0 comments on commit b38fe8a

Please sign in to comment.