-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
435 additions
and
191 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
contract ApplicationDelegate{ | ||
|
||
address user; | ||
|
||
bytes32 private salt; | ||
bytes32 private challenge; | ||
bytes20 private response; | ||
|
||
event error(string msg); | ||
event success(string msg); | ||
|
||
|
||
function PasswordDelegate(address _user, bytes20 _response, bytes32 _salt){ | ||
user = _user; | ||
response = _response; | ||
salt = _salt; | ||
challenge = sha3(now); | ||
} | ||
|
||
function getSalt() constant returns(bytes32){ | ||
return salt; | ||
} | ||
|
||
function getChallenge() constant returns(bytes32){ | ||
return challenge; | ||
} | ||
|
||
function getResponse() constant returns(bytes20){ | ||
return response; | ||
} | ||
|
||
function authorize(uint8 v, bytes32 r, bytes32 s, address grant) { | ||
if(bytes20(ecrecover(challenge, v, r, s)) != response) return error('Incorrect password'); | ||
User(user).authorize(grant); | ||
challenge = sha3(challenge); | ||
return success('Authentication successfull'); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
contract Delegate{ | ||
|
||
event error(); | ||
event success(); | ||
|
||
function authorize(uint8 v, bytes32 r, bytes32 s, address party, address grant){} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
contract FacebookDelegate{ | ||
|
||
address user; | ||
|
||
bytes32 private salt; | ||
bytes32 private challenge; | ||
bytes20 private response; | ||
|
||
event error(string msg); | ||
event success(string msg); | ||
|
||
|
||
function PasswordDelegate(address _user, bytes20 _response, bytes32 _salt){ | ||
user = _user; | ||
response = _response; | ||
salt = _salt; | ||
challenge = sha3(now); | ||
} | ||
|
||
function getSalt() constant returns(bytes32){ | ||
return salt; | ||
} | ||
|
||
function getChallenge() constant returns(bytes32){ | ||
return challenge; | ||
} | ||
|
||
function getResponse() constant returns(bytes20){ | ||
return response; | ||
} | ||
|
||
function authorize(uint8 v, bytes32 r, bytes32 s, address grant) { | ||
if(bytes20(ecrecover(challenge, v, r, s)) != response) return error('Incorrect password'); | ||
User(user).authorize(grant); | ||
challenge = sha3(challenge); | ||
return success('Authentication successfull'); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
contract Grant { | ||
|
||
address app; | ||
address user; | ||
address client; | ||
address owner; | ||
|
||
function Grant() { | ||
app = msg.sender; | ||
function Grant(address _client) { | ||
client = _client; | ||
} | ||
|
||
/* | ||
* authorize the grant contract | ||
* this can only be done once | ||
*/ | ||
function authorize() { | ||
user = msg.sender; | ||
if(msg.sender != owner) throw; | ||
owner = msg.sender; | ||
} | ||
|
||
function state() constant returns (address b, address a){ | ||
a = app; | ||
b = user; | ||
/* | ||
* revoke the grant contract | ||
* this can be done by the client or owner | ||
*/ | ||
function revoke() { | ||
if(msg.sender != client && msg.sender != owner) throw; | ||
suicide(msg.sender); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
contract Party { | ||
|
||
mapping (address => bool) delegates; | ||
|
||
/* | ||
* constructor set sender as first delegate | ||
*/ | ||
function Party () { | ||
delegates[msg.sender] = true; | ||
} | ||
|
||
/* | ||
* authorize contract of type grant | ||
*/ | ||
function authorize (address grant) { | ||
if(!delegates[msg.sender]) throw; | ||
Grant(grant).authorize(); | ||
} | ||
|
||
/* | ||
* enroll new address as delegate to the contract | ||
*/ | ||
function enroll (address delegate) { | ||
if(!delegates[msg.sender]) throw; | ||
delegates[delegate] = true; | ||
} | ||
|
||
/* | ||
* abandon a delegate from the contract | ||
*/ | ||
function abandon (address delegate) { | ||
if(!delegates[msg.sender]) throw; | ||
if(!delegates[delegate]) throw; | ||
delete delegates[delegate]; | ||
} | ||
|
||
} |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,5 @@ | ||
var Web3 = require('web3'); | ||
var web3 = new Web3(); | ||
|
||
var defaultProvider = new web3.providers.HttpProvider("http://128.199.53.68:8545") | ||
|
||
web3.setProvider(defaultProvider); | ||
web3.eth.defaultAccount = web3.eth.coinbase; | ||
|
||
var source = "contract test { function multiply(uint a) constant returns(uint d) {return a * 7;}}"; | ||
|
||
var compiled = web3.eth.compile.solidity(source); | ||
var abi = compiled.test.info.abiDefinition; | ||
var code = compiled.test.code; | ||
|
||
function createContract(callback){ | ||
web3.eth.contract(abi).new({ | ||
from: web3.eth.coinbase, | ||
gas: 500000, | ||
data: code | ||
}, callback); | ||
} | ||
|
||
module.exports = createContract; | ||
module.exports = { | ||
contracts: require('./contracts'), | ||
services: require('./services'), | ||
jwt: require('./jwt') | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
passwordDelegateServices: require('./services/passwordDelegateServices') | ||
}; |
Oops, something went wrong.