An elliptic curve is made up of the following:
- A field, F_p.
- What this means is all arithmetic on scalars is modulo p.
- Modern ECC have p as some large prime.
- For curve25519, p = 2^255 - 19, a prime.
- An equation and it's parameters:
| [ | |
| { | |
| "lang": "en", | |
| "viewStrings" : [ | |
| { | |
| "viewKey" : "LoginView", | |
| "strings" : { | |
| "Title" : "Login", | |
| "SignUpButtonTitle" : "Sign up" | |
| } |
| // We don't know the return value of this function! Makes it hard to debug! | |
| func fetchUserByFirstName(firstName: String, andLastName lastName: String, fromContext context: NSManagedObjectContext) -> User? { | |
| defer { | |
| // Not possible, would be nice! Return value would be an implicitly declared variable | |
| // exaclty like the variables 'newValue' and 'oldValue' in property observers! | |
| print("return value: \(returnValue)") | |
| } | |
| guard !firstName.isEmpty else { print("firstName can't be empty"); return nil } | |
| guard !lastName.isEmpty else { print("lastName can't be empty"); return nil } |
| postfix operator ⁉️ | |
| postfix func ⁉️ <Value>(optional: Optional<Value>) -> Value { | |
| return optional! as Value | |
| } | |
| //USAGE | |
| let maybeString: String? = "Foobar" | |
| let maybeString2: String? = nil | |
| print(maybeString⁉️) //prints "Foobar" |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| import RxOptional | |
| public protocol OptionalType { | |
| associatedtype OptionalElement | |
| var element: OptionalElement? { get } | |
| func asOptional() -> OptionalElement? | |
| func asNil() -> OptionalElement? | |
| } | |
| public extension OptionalType { |
| #!/usr/bin/python3 -O | |
| from math import floor, log | |
| def montgomery_ladder(x, n, op, select): | |
| k = floor(log(n, 2)) + 1 | |
| x1 = x | |
| x2 = op(x, x) | |
| for i in range(k - 2, -1, -1): | |
| bit = 1 if n & (1 << i) else 0 |
| import random | |
| class Montgomery: | |
| # B*v^2 = u^3 + A*u^2 + u | |
| def __init__(self, A, B, p): | |
| self.A = A | |
| self.B = B | |
| self.p = p |
| import Foundation | |
| extension UnicodeScalar : ForwardIndexType { | |
| public func successor() -> UnicodeScalar { | |
| return UnicodeScalar(value + 1) | |
| } | |
| } | |
| var operatorHeads: [UnicodeScalar] = Array("=-+!*%<>&|^~?".unicodeScalars) | |
| operatorHeads += Array("\u{00A1}" ... "\u{00A7}") |
| /// A dictionary wrapper that uses a `CaseIterable` type as its key. | |
| /// This differs from a dictionary in two ways: | |
| /// | |
| /// - Key-value pairs are accessed in a fixed order, which is the same | |
| /// as the `Key`'s `allCases` property. | |
| /// - Every possible key must have a value given, so using the key-based | |
| /// subscript returns a non-optional value. | |
| struct CaseMap<Key: CaseIterable & Hashable, Value> : Collection { | |
| typealias Index = Key.AllCases.Index | |