Skip to content

Commit

Permalink
Fix initializer with zkLogin Signature type, add partial
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Arnett committed Apr 9, 2024
1 parent 5436ff8 commit bc76c9a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
46 changes: 46 additions & 0 deletions Sources/SuiKit/Utils/zkLogin/PartialZkLoginSignature.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// PartialZkLoginSignature.swift
// SuiKit
//
// Copyright (c) 2024 OpenDive
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

public struct PartialZkLoginSignature: KeyProtocol, Equatable, Codable {
public var proofPoints: zkLoginSignatureInputsProofPoints
public var issBase64Details: zkLoginSignatureInputsClaim
public var headerBase64: String

public func serialize(_ serializer: Serializer) throws {
try Serializer._struct(serializer, value: self.proofPoints)
try Serializer._struct(serializer, value: self.issBase64Details)
try Serializer.str(serializer, self.headerBase64)
}

public static func deserialize(from deserializer: Deserializer) throws -> PartialZkLoginSignature {
return PartialZkLoginSignature(
proofPoints: try Deserializer._struct(deserializer),
issBase64Details: try Deserializer._struct(deserializer),
headerBase64: try Deserializer.string(deserializer)
)
}
}
12 changes: 12 additions & 0 deletions Sources/SuiKit/Utils/zkLogin/zkLoginSignatureInputs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ public struct zkLoginSignatureInputs: KeyProtocol, Equatable {
public var headerBase64: String
public var userSignature: String

public init(
proofPoints: zkLoginSignatureInputsProofPoints,
issBase64Details: zkLoginSignatureInputsClaim,
headerBase64: String,
userSignature: String
) {
self.proofPoints = proofPoints
self.issBase64Details = issBase64Details
self.headerBase64 = headerBase64
self.userSignature = userSignature
}

public func serialize(_ serializer: Serializer) throws {
try Serializer._struct(serializer, value: self.proofPoints)
try Serializer._struct(serializer, value: self.issBase64Details)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import Foundation

public struct zkLoginSignatureInputsClaim: KeyProtocol, Equatable {
public struct zkLoginSignatureInputsClaim: KeyProtocol, Equatable, Codable {
public var value: String
public var indexMod4: UInt8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import Foundation

public struct zkLoginSignatureInputsProofPoints: KeyProtocol, Equatable {
public struct zkLoginSignatureInputsProofPoints: KeyProtocol, Equatable, Codable {
public var a: [String]
public var b: [[String]]
public var c: [String]
Expand Down

0 comments on commit bc76c9a

Please sign in to comment.