This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Date { | |
init(date: NSDate) { | |
self.init(timeIntervalSinceReferenceDate: date.timeIntervalSinceReferenceDate) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open specified xcode project or worspace, or open a workspace or project in specified directory | |
xcode() { | |
dir=`pwd` | |
if [[ "$1" != "" ]] ; then | |
if [ ! -d $1 ] ; then | |
open -a Xcode $1 | |
return | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Activate a named docker machine | |
docker-machine-set-active() { | |
eval $(docker-machine env $1) | |
} | |
# Create digital ocean droplet | |
docker-create-droplet() { | |
if [[ "$1" == "" || "$2" == "" || "$3" == "" ]] ; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val acc = RSAAccumulator() | |
val app = Javalin.create().start(7000) | |
app.get("/commitment") { ctx -> | |
ctx.result(acc.commitment.toString(10)) | |
} | |
app.put("/add/:member") { ctx -> | |
val member = ctx.pathParam("member") | |
acc.add(member) | |
ctx.json(ProofResponse(acc.proveMembership(member))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val app = Javalin.create().start(7000) | |
app.post("/verify") { ctx -> | |
val body = ctx.bodyAsClass(VerifyBody::class.java) | |
ctx.json(RSAAccumulator.verifyMembership(BigInteger(body.commitment), body.proof)) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun add(x: BigInteger): RSACommit { | |
return if (data.containsKey(x)) { | |
commitment | |
} else { | |
val (hashPrime, nonce) = hashToPrime(x, ACCUMULATED_PRIME_SIZE) | |
commitment = commitment.modPow(hashPrime, n) | |
data[x] = nonce | |
commitment | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun proveMembershipOrNull(x: BigInteger): RSAProof? { | |
return if (!data.containsKey(x)) { | |
null | |
} else { | |
var product = BigInteger.ONE | |
for ((k, v) in data) { | |
if (k != x) { | |
product *= hashToPrime(k, ACCUMULATED_PRIME_SIZE, v).first | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun verifyMembership(A: BigInteger, x: BigInteger, proof: BigInteger): Boolean { | |
return proof.modPow(x, n) == A | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate: UIResponder, UIApplicationDelegate { | |
@objc public var window: UIWindow? | |
@objc public let services: [UIApplicationDelegate] = [ | |
PersistenceService(), | |
AnalyticsService(), | |
CrashReporterService() | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppServicesSwift-Swift.h" | |
@implementation AppDelegate (Forward) | |
- (void)forwardInvocation:(NSInvocation *)anInvocation | |
{ | |
for (UIResponder<UIApplicationDelegate> *service in self.services) { | |
if ([service respondsToSelector: anInvocation.selector]) { | |
[anInvocation invokeWithTarget: service]; | |
} |